您可以使用RTLabel为,
在代码中添加该库比按照此步骤,
在.h文件中添加以下代码
//Import RTLabel
#import "RTLabel.h"
// Add delegate
@interface ViewController : UIViewController<RTLabelDelegate>
@end
而且在.m文件
- (void)viewDidLoad {
RTLabel *label = [[RTLabel alloc] initWithFrame:CGRectMake((self.view.frame.size.width-262)/2, (self.view.frame.size.height-203)/2, 262, 203)];
label.delegate = self;
// You have to create link for each name
NSString *searchString = @"<a href=\"Dilip\">Dilip</a> <a href=\"Dev\">Dev</a> <a href=\"Ram\">Ram</a>";
}
//RTLabel Delegate Method
- (void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSURL*)url
{
//When user click on one of the name this method will called and url will return the name which user has tapped. You can add condition on name that which view will display.
NSLog(@"did tap on name %@", url);
}
只要你选择一个UIButton,将titleLabel设置为名称,然后将动作设置为任何你想要的。 – Jonathan