- (NSMutableAttributedString *)setPromptTitle:(NSString *)title {字體
NSString * textmessage = [NSString stringWithFormat:@"%@", title];spa
NSMutableAttributedString *fontString = [[NSMutableAttributedString alloc] initWithString:textmessage];orm
[fontString addAttribute:NSForegroundColorAttributeName value:[UIColor ip
colorFromHexString:@"#f3f3f3"ci
] range:NSMakeRange(0,2)];
字符串
[fontString addAttribute:NSForegroundColorAttributeName value:[UIColor string
colorFromHexString:@"#d0d0d0"it
] range:NSMakeRange(1,fontString.length - 2)];
table
return fontString;iconfont
}
1.NSForegroundColorAttributeName設置文本字體顏色的標示,默認blackColor
[fontString addAttribute:NSForegroundColorAttributeName value:[UIColor colorFromConfigColor:JDTextSecondTitleColor] range:NSMakeRange(0,2)];
rang:特殊處理字符串的位置,好比range:NSMakeRange(0,2)表示:從下標0位置開始,向左移動2位。
2.NSFontAttributeName設置字體的粗細大小
[fontString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"iconfont" size:12 * [AdapterRect adapterMultipleByWidth]] range:NSMakeRange(0,1)];
fontWithName:@"iconfont"是自定義字體的iconfont的縮寫。你也能夠直接設置[UIFont systemFontOfSize:12 * [AdapterRect adapterMultipleByWidth]]