//聯(lián)系人:石虎QQ:1224614774昵稱:嗡嘛呢叭咪哄
一、概念效果圖:
圖1:
二帆精、小數(shù)點(diǎn)實(shí)現(xiàn)代碼
- (void)viewDidLoad {
[superviewDidLoad];
NSString *text =@"12345.6789";
NSString *floStr;
NSString *intStr;
if([text containsString:@"."]) {
NSRange range = [text rangeOfString:@"."];
floStr = [text substringFromIndex:range.location];
intStr = [text substringToIndex:range.location];
}
UILabel *introLabel = [UILabel lableFrame:CGRectZero title:nilbackgroundColor:[UIColor clearColor] font:kGlobalFontSize_28 textColor:[UIColor purpleColor]];
NSMutableAttributedString *indroStr = [NSMutableAttributedString setupAttributeString:text rangeText:intStr textColor:OKColorRGB(236,198,128)];
introLabel.attributedText = indroStr;
introLabel.frame = CGRectMake(10,100,500,40);
[selfaddSubview:introLabel];
}
注意:封裝方法--鏈接:http://blog.csdn.net/shihuboke/article/details/78390255,只是在基礎(chǔ)上判斷小數(shù)點(diǎn)的字體大小和顏色