作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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/
我是一名优秀的程序员,十分优秀!