Ios 删除AttributeText xcode末尾的点
你好。。我是ios、swift和xcode的新手 我在swift文件中有如下逻辑:Ios 删除AttributeText xcode末尾的点,ios,swift,xcode,Ios,Swift,Xcode,你好。。我是ios、swift和xcode的新手 我在swift文件中有如下逻辑: class ExpandableHeaderView: UITableViewHeaderFooterView { func customInit(menu: Menu, section: Int, delegate: ExpandableHeaderViewDelegate) { //Create Attachment let imageAttachment =
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
:
}
}
但我得到的结果是:
我已经为所有NSLineBreakMode.by*
添加了,但是没有人能够完美地显示图像和标签:[image]Home
如何删除textlab?.attributedText
末尾的3个点
我真的很困惑
所以,我很高兴有人能帮助我
环境:
我不认为用“…”来截断你的标签是个问题。您应该首先确定标签的正确大小。隐藏此
self.textLabel?.lineBreakMode=NSLineBreakMode。通过截断邮件
并检查\标签似乎太窄。是否向标签添加了任何宽度限制?请尝试textLabel.numberOfLines=0@chirag90我尝试添加textlab.numberOfLines=0
,但得到了相同的结果issue@Anbu.karthik我禁用/评论了self.textlab?.lineBreakMode=NSLineBreakMode.bTruncatingTail`仍然存在相同的问题…您是如何添加标签的?它们是添加在故事板还是Xib文件中?如果是这样,您应该通过使用Interface Builder向标签添加所需的约束来解决大小问题。@andlin我添加的标签不在情节提要
,而是在Swift
文件中。.你好,鲁迪,请尝试本教程:| www.raywenderlich.com通常都有很好的教程,因此请毫不犹豫地开始学习;-)