删除attributionText xcode末尾的点

时间:2018-05-21 12:48:26

标签: ios swift xcode

Heloo ..我是ios,swift和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


        :
    }

}

但我的结果如下:

enter image description here

我添加了所有NSLineBreakMode.by*,但没有人能够显示图片和标签:[image] Home

如何删除textLabel?.attributedText的最后3个点?

我真的很困惑......

所以,我很高兴有人能帮助我......

ENV:

  1. xCode v.9.3

1 个答案:

答案 0 :(得分:1)

我不会考虑用" ..."来截断你的标签。作为一个问题。您应该首先解决标签的正确尺寸。