【发布时间】:2010-05-03 05:33:24
【问题描述】:
如何将 UIPickerview 中每一行的标题向右对齐?
提前致谢。
【问题讨论】:
标签: iphone uipickerview
如何将 UIPickerview 中每一行的标题向右对齐?
提前致谢。
【问题讨论】:
标签: iphone uipickerview
您可以实现委托的pickerView:viewForRow:forComponent:reusingView: 方法并从中返回 UILabel 实例:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* label = (UILabel*)view;
if (view == nil){
label= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 190, 44)];
label.textAlignment = UITextAlignmentRight;
//Set other properties if you need like font, text color etc
...
}
label.text = [self textForRow:row forComponent:component];
return label;
}
【讨论】: