How can I right align text in a UIPickerView
? I tried to make custom UILabel
s for the row views, but for some reason, nothing is showing up, right-aligned or otherwise. Here's what I wrote:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setText:[NSString stringWithFormat:@"row %d", row]];
[label setTextAlignment:UITextAlignmentRight];
return [label autorelease];
}
In case anyone is wondering, I used CGRectZero
because I saw it in the UICatalog
example.