首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

UIPickerView NSAttributedString 设置字体大小无效解决方案

2014-01-08 
UIPickerView NSAttributedString 设置字体大小无效我现在有一个UIPickerView,我实现了它的代理- (NSAttri

UIPickerView NSAttributedString 设置字体大小无效
我现在有一个UIPickerView,我实现了它的代理- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
在这个代理里面,我想设置每个componet的文字及大小,颜色,如下所示
NSString *strDateWeek = [self getDateAndWeekByRow:row];

NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:strDateWeek];
UIFont *font = [UIFont fontWithName:macroFontBoldNameStr size:fontSize];
[attrString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, strDateWeek.length)];
return attrString;
在ios6上运行起来,一切正常,和期望的一样。可是在ios7上,却死活改不了字体的大小,那么大的字体放在那,那叫一个丑呀。
求助各位,在ios7上,这里要怎样改变字体的大小呀?
拿ios7 我都烦死了。。之前实现的-(UIView *) pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view这个代理方法,ios6上跑起来也挺顺的,可是在ios7上却卡顿了,原因是ios6上返回的view可以复用,而ios7上却需要每次都新建。今天换了上面的方法,ios7又不能改字体,哎。。。
[解决办法]
据我所知,在iOs7里要现实你的功能,只能用 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view 了,而且如果实在卡顿的话就不要addsubview,直接drawRect代替试试
[解决办法]
为了积分.......

热点排行