我想使Facebook的标题UILabel。
我想要做的事情是在UILabel或UITextView中多次触摸。我应该使用什么?
我该如何制作这样的http://tool.keepitreal.jp/screen.png?
在这种情况下,如果您触摸,每个名称将转到不同的页面。我怎么能把多个触摸像UILabel/UITextView的Facebook标题?
NSString* parts = @"this is test. you know?";
NSError *error = nil;
NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"test" options:0 error:&error];
if (error == nil) {
NSArray *res = [regexp matchesInString:parts.string options:0 range:NSMakeRange(0, parts.length)];
for (NSTextCheckingResult *match in res) {
// change color
[parts addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:[match rangeAtIndex:0]];
}
}
使用[NSMutableAttributedString](https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSMutableAttributedString_Class/Reference/Reference.html)。 –
我试过NSMutableAttributedString。我可以更改字体重量,但是我怎样才能在每个名字上设置事件。 – naohide
@naofide:显示你试过的东西?你有使用'addAttribute'属性吗? –