一、调整UILabel的行距ui
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:cLabelString];spa
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];3d
[paraStyle setLineSpacing:28];orm
[attStr addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, attStr.length)];图片
cLabel.attributedText = attStr;ci
[cLabel sizeToFit];get
二、UILabel文字加删除线it
NSDictionary *sub1 = @{NSForegroundColorAttributeName:[UIColor redColor],NSStrikethroughStyleAttributeName:@2};//后面数字是用来调整删除线的粗细io
NSString *strDisplayText3 = @"Red and Green" ;table
NSMutableAttributedString *attributedText3 = [[ NSMutableAttributedString alloc ] initWithString :strDisplayText3];
[attributedText3 setAttributes :sub1 range : NSMakeRange ( 0 , 3 )];
cLabel.attributedText = attributedText3;
这个仍是保存下来吧~http://www.tuicool.com/articles/FBRrUjZ
三、造图片,用于设置按钮点击的颜色
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}