UILabel子类:MCGifEmojiLabel
jopen
10年前
MCGifEmojiLabel 是一款用户友好的 UILabel 子类,允许开发者以动图的形式显示emoji,同时允许自行添加链接。借鉴了 OHAttributedLabel 的部分代码。
使用非常方便:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
MCGifEmojiLabel* label = [[MCGifEmojiLabel alloc] initWithFrame:CGRectMake(10, 100, 300, 100)];
[label setTextWithEmoji:@"When I was young I'd listen to the radio(#laughing),waiting for my favorite songs(#smiling).When they played I'd sing along(#flushed).It made me smile."];
[label addCustomLink:[NSURL URLWithString:@"https://github.com"] inRange:NSMakeRange(0, 40)];
label.highlightedLinkColor = [UIColor grayColor];
label.lineBreakMode = NSLineBreakByWordWrapping;
[self.view addSubview:label];
}
预览: