如何将每行上的选取器视图标题文本对齐到右边?

Het*_*ora 3 iphone uipickerview

如何将UIPickerview中每行的标题右对齐?

提前致谢.

Vla*_*mir 7

您可以实现委托的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;
}
Run Code Online (Sandbox Code Playgroud)