- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 Storyboard 来设置 UILabel
的行数 (4) 和换行符(截尾)。
This is what i have right now:
我的问题是如何截断/触发截断?
This is what i want to achieve:
更新:
只是为了让我的问题更清楚。
我不想像默认 UILabel
的行为那样剪切 UILabel
中的实际字符串。
使用 NSLog(@"%@", myLabel.text);
时第一张图片生成的日志是分配给它的完整字符串,这就是我试图实现的行为.
在我的例子中是:
A little girl was talking to her teacher about whales. The teacher said it was physically impossible for a whale to swallow a human because even though it was a very large mammal.
Making my question clearer:
如何在不剪切实际的情况下截断/触发截断 NSString
分配给它?
或者可能会解决这个问题,这有可能吗?
最佳答案
您可以使用 TTTAttributedLabel图书馆
例如:
声明:
@property (strong, nonatomic) IBOutlet TTTAttributedLabel *lblTT;
带有 setAttributedTruncationToken
的示例代码:
NSDictionary *attr = @{NSForegroundColorAttributeName : [UIColor redColor]};
NSAttributedString *str = [[NSAttributedString alloc] initWithString:@"...Continue Reading" attributes:attr];
[self.lblTT setAttributedTruncationToken:str];
希望对你有所帮助。
如果您不想使用现成的类(class),请检查此答案:How to add button to the end of text like Facebook's "Continue reading"?
关于ios - UILabel 换行截尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31420543/
在 Vaadin 7.0,显示时JavaBean Table 中的数据与 BeanContainer ,用新数据刷新表的正确方法是什么? 最佳答案 该表通过监听器监视表项的属性。如果您通过表的 Ite
首先,我使用的是带有 Axis2 1.6.2 的 eclipse,我正在 tomcat 6 上部署我创建的 Web 服务。Web 服务是在 eclipse 中通过自上而下的方法创建的。 我被要求使对我
我已将 Rails 3.1.1 应用程序升级到 Rails 3.1.3,现在,对于每个请求,它仅响应错误数量的参数(3 for 1)。不幸的是,它没有说明错误在哪里,并且应用程序跟踪为空。我认为存在一
我是一名优秀的程序员,十分优秀!