我想使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'屬性嗎? –