数据来自解析器,如果文本超过120个字符,那么它应该附加" ... ReadMore"就像facebook一样。我有附加文本的代码,但不知道如何制作可点击的链接。我使用的是Swift Languange。
if cell!.bhikmangaTextlbl!.text!.utf16Count >= 120
{
var abc : String = (cell!.bhikmangaTextlbl!.text! as
NSString).substringWithRange(NSRange(location: 0, length: 120))
abc += " ...ReadMore"
cell!.bhikmangaTextlbl!.text = abc
}
答案 0 :(得分:1)
您可以在此处使用属性字符串...并使文本的某些部分可点击
这里是Objective C代码。您可以为Swift编写相同的内容
NSDictionary *attribs = @{
NSForegroundColorAttributeName: BODY_FONT_COLOR,
NSFontAttributeName: [UIFont fontWithName:FontHelvetica size:AppFont16]
};
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:ACCIDENT_DETECTION_AUTOMATIC_TEXT attributes:attribs];
[attributedString addAttribute:NSLinkAttributeName
value:@"Accident detection"
range:[[attributedString string] rangeOfString:@"Read More"]];
NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: LINKS_FONT_COLOR,
NSUnderlineColorAttributeName: [UIColor clearColor],
NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)};
// assume that textView is a UITextView previously created (either by code or Interface Builder)
self.accidentDetectionText.linkTextAttributes = linkAttributes; // customizes the appearance of links
self.accidentDetectionText.attributedText = attributedString;
答案 1 :(得分:0)
好吧,我宁愿添加一个名为&#34的额外标签;阅读更多"并在其上添加点击手势以扩展第一个标签。