gpt4 book ai didi

iphone - objective-c : Write a function to return the position of the last character in a UILabel?

转载 作者:行者123 更新时间:2023-12-03 21:24:22 27 4
gpt4 key购买 nike

UILabel 的文本是在 CGRect(x,y,size,width) 中绘制的。标签可以有多行文本。

是否可以编写一个函数来返回此矩形内的 CGPoint,该 CGPoint 指定最后一个字符的位置?

我问这个问题是因为我试图将 UILabel 的文本包装在任意前缀和后缀中。前缀/后缀需要是单独的标签,以便我可以设置它们的字体、颜色等。找到文本的开头很容易,但找到文本的结尾却很棘手,至少对我来说是这样。

最佳答案

也许 UIWebView 可以解决这个问题。填充 [webview LoadHTMLString:@"<b>prefix/b>text<b>suffix</b>" baseURL:nil] 。这是一个有点大锤的解决方案,但显然你会得到很多其他的好东西。

关于iphone - objective-c : Write a function to return the position of the last character in a UILabel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1965059/

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