我想在UILabel中创建以下示例文本.
Muthu:嗨,我正在去办公室的路上......
等几分钟......
这种类型的文本有UITableviewCustom单元格有UILabel.
如何在UILabel中创建?
使用以下代码并包含以下链接"https://github.com/AliSoftware/OHAttributedLabel"中的.h和.m文件.
-(void)addTitleView{
NSMutableAttributedString* attrStr = [NSMutableAttributedString attributedStringWithString:@"Muthu: Hi I am on the way to office..wait for the few mins..."];
[attrStr setFont:[UIFont fontWithName:@"Verdana" size:16]];
[attrStr setTextColor:[UIColor whiteColor]];
[attrStr setFont:[UIFont fontWithName:@"Verdana-Bold" size:16] range:NSMakeRange(0,6)];
OHAttributedLabel *titleLabel = [[OHAttributedLabel alloc] init];
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[titleLabel setFrame:CGRectMake(0, 0, 200, 35)];
[titleLabel setBackgroundColor:[UIColor clearColor]];
titleLabel.adjustsFontSizeToFitWidth = YES;
titleLabel.attributedText = attrStr;
titleLabel.textAlignment = UITextAlignmentJustify;
[self.view addSubview:titleLabel];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5832 次 |
| 最近记录: |