Iphone 如何更改UIPicker中字符的大小
我试图在UIPicker中居中并更改文本大小,但不确定如何。。。我认为这可能发生在这些方法中的一种,最有可能是第一种Iphone 如何更改UIPicker中字符的大小,iphone,ios,uipicker,text-size,Iphone,Ios,Uipicker,Text Size,我试图在UIPicker中居中并更改文本大小,但不确定如何。。。我认为这可能发生在这些方法中的一种,最有可能是第一种 - (NSString*)pickerView:(UIPickerView*)pv titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [[NSString stringWithFormat:@"%x",row ] uppercaseString]; //Sets picker opt
- (NSString*)pickerView:(UIPickerView*)pv titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [[NSString stringWithFormat:@"%x",row ] uppercaseString]; //Sets picker options as an Uppercase Hex value
}
#pragma mark UIPickerViewDataSource methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pv
{
return 5; //5 columns in the picker
}
- (NSInteger)pickerView:(UIPickerView*)pv numberOfRowsInComponent:(NSInteger)component
{
return 16;
}
有人知道怎么做吗?我四处查看了一下,但是文档很薄…约翰
与在表视图中一样,您不能更改通常在titleForRow委托方法中设置的默认标题的字体属性,而是必须使用以下方法:
- (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component
在这里,您可以使用自定义UILabel创建UIView,并设置标签的字体大小、颜色和其他属性
此方法如中所述
希望这对你有帮助 现在,在iOS 6上,您可以使用NSAttributedString自定义标题文本(尽管我认为这不便于将文本居中) 新的UIPickerViewDelegate方法允许您返回属性化字符串,而不是普通字符串: (NSAttributedString*)pickerView:(UIPickerView*)pickerView attributedTitleForRow:(NSInteger)组件的行:(NSInteger)组件 NSAttributedString UIKit additions页面包含可控制的所有字符属性的列表:
哇。。。这真让人失望。。你可能认为苹果会在titleForRow委托方法中涵盖这类内容。