一、調整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;
}