gpt4 book ai didi

ios - 删除 attributedText xcode 末尾的点

转载 作者:行者123 更新时间:2023-11-28 14:42:26 24 4
gpt4 key购买 nike

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 个点?

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

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

环境:

  1. xCode 9.3 版

最佳答案

我不认为用“...”截断您的标签是个问题。您应该首先解决标签的正确尺寸问题。

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com