你好。。我是ios的新手,斯威夫特和xcode。。。
我在swift文件中有如下逻辑:

class ExpandableHeaderView: UITableViewHeaderFooterView {

    func customInit(menu: Menu, section: Int, delegate: ExpandableHeaderViewDelegate) {

        //Create Attachment

        let imageAttachment =  NSTextAttachment()

        var textAfterIcon: NSMutableAttributedString

        switch menu {

        case .HOME:

            imageAttachment.image = UIImage(named:"home")

            textAfterIcon = NSMutableAttributedString(string: " Home")

        :

        }

        //Set bound to reposition
        let imageOffsetY:CGFloat = -3.0;
        imageAttachment.bounds = CGRect(
            x: 0,
            y: imageOffsetY,
            width: imageAttachment.image!.size.width,
            height: imageAttachment.image!.size.height)
        //Create string with attachmen
        let attachmentString = NSAttributedString(attachment: imageAttachment)
        //Initialize mutable string
        let completeText = NSMutableAttributedString(string: "")
        //Add image to mutable string
        completeText.append(attachmentString)
        //Add your text to mutable string
        completeText.append(textAfterIcon)
        self.textLabel?.lineBreakMode = NSLineBreakMode.byTruncatingTail

        self.textLabel?.attributedText = completeText


        :
    }

}

但我得到的结果是:
ios - 删除attributedText xcode末尾的点-LMLPHP
我已经添加了所有NSLineBreakMode.by*,但没有人是完美的显示图像和标签:[image] Home
如何删除textLabel?.attributedText的最后3个点?
我真的很困惑。。。
所以,我很高兴有人能帮助我。。。
环境:
X代码v.9.3

最佳答案

我不认为把你的标签删去“…”是个问题。你应该首先解决正确的标签大小。

关于ios - 删除attributedText xcode末尾的点,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50449283/

10-11 04:35