带属性的字符串:
NSString *aa = @"hellochinaIloveYou!";
NSMutableAttributedString *mas = [[NSMutableAttributedString alloc]initWithString:aa]; // 设置字符串字属性
UIFont *font = [UIFont fontWithName:@"Arial" size:35.0f];
[mas addAttribute:NSFontAttributeName value:font range:NSMakeRange(, )];
// 设置字体颜色
[mas addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(, )];
// 设置背景色
[mas addAttribute:NSBackgroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(, )];
// 设置字符间距
[mas addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:10.1] range:NSMakeRange(, )];
// 设置删除线线型
[mas addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:] range:NSMakeRange(, )];
// 设置删除线颜色
[mas addAttribute:NSStrikethroughColorAttributeName value:[UIColor greenColor] range:NSMakeRange(, )];
// 设置字体倾斜
[mas addAttribute:NSObliquenessAttributeName value:[NSNumber numberWithFloat:0.6] range:NSMakeRange(, )];
// 拉伸字体
[mas addAttribute:NSExpansionAttributeName value:[NSNumber numberWithFloat:0.9] range:NSMakeRange(, )];
// 设置下划线
[mas addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(, )];
// 设置下划线颜色
[mas addAttribute:NSUnderlineColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(, )];
// 设置搂空字体
[mas addAttribute:NSStrokeWidthAttributeName value:[NSNumber numberWithInt:] range:NSMakeRange(, )];
// 搂空字体设置颜色
[mas addAttribute:NSStrokeColorAttributeName value:[UIColor redColor] range:NSMakeRange(, )];
// 设置阴影
NSShadow *shadow = [[NSShadow alloc]init];
shadow.shadowBlurRadius = ;
shadow.shadowColor = [UIColor colorWithRed:0.502 green:0.023 blue:0.134 alpha:1.000];
shadow.shadowOffset = CGSizeMake(-0.1, 0.1);
[mas addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(, )];
// 设置印刷字体
[mas addAttribute:NSTextEffectAttributeName value:NSTextEffectLetterpressStyle range:NSMakeRange(, )]; UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
// label.text = mas.string;
label.attributedText =mas; [self.view addSubview:label];