#import"ViewController.h"
@interfaceViewController()
@property(weak,nonatomic)IBOutletUIButton*loginbutton;
@property(weak,nonatomic)IBOutletUILabel*lable;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
//**用富文本快速设置Label的文字:字体,大小,颜色
NSMutableParagraphStyle*ps = [[NSMutableParagraphStylealloc]init];
//可以通过ps设置行距,间距,对齐方式,拆行方式
[pssetAlignment:NSTextAlignmentCenter];// 居中对齐
NSDictionary*attribs=@{
NSFontAttributeName: [UIFontfontWithName:@"Verdana"size:50],
NSForegroundColorAttributeName:[UIColorredColor],NSParagraphStyleAttributeName:ps};
NSMutableAttributedString*attributedText =[[NSMutableAttributedStringalloc]initWithString:self.lable.textattributes:attribs];
self.lable.attributedText= attributedText;
//**用富文本快速设置UIbutton Title的文字:字体,大小,颜色
NSMutableAttributedString*attributedTextForButton =[[NSMutableAttributedStringalloc]initWithString:self.loginbutton.titleLabel.textattributes:attribs];
[self.loginbuttonsetAttributedTitle:attributedTextForButtonforState:UIControlStateNormal];
// Do any additional setup after loading the view, typically from a nib.
}
网友评论