uilabel的字體不一致

UILabel *pLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,100,200,100)];

pLabel.text = @”測試到嗎”;
NSInteger leght = [pLabel.text length];
NSMutableAttributedString *richText = [[NSMutableAttributedString alloc] initWithString:pLabel.text];
//設置特殊字段的大小,顏色,字體
[richText addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:16.0] range:NSMakeRange(0, leght)];//設置字體大小
[richText addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, leght)];//設置字體顏色
[richText addAttribute:NSObliquenessAttributeName value:@1 range:NSMakeRange(0, leght)];//設置的是斜體
[richText addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleDouble] range:NSMakeRange(0, leght)];//設置下劃線
[richText addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0,leght)];//設置刪除線
[richText addAttribute:NSStrikethroughColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, leght)];//設置刪除線的顏色
//屬性參數
NSFontAttributeName //字體 默認是12號
NSParagraphStyleAttributeName//段落樣式
NSForegroundColorAttributeName//指定字體顏色
NSBackgroundColorAttributeName//字體背景顏色
NSLigatureAttributeName//連體字符
NSKernAttributeName//字距的像素
NSStrikethroughStyleAttributeName//指定字上加刪除線
NSUnderlineStyleAttributeName//指定字加下劃線
NSStrokeColorAttributeName//填充部分顏色
NSStrokeWidthAttributeName//填充寬度
NSShadowAttributeName//陰影
NSUnderlineColorAttributeName//下劃線顏色

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章