read

Use ‘viewForRow’ instead of ‘titleForRow’, like this:

<pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> // Used this instead of titleForRow to allow center aligment of text
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] init];
//For center alignment of text
[label setTextAlignment:UITextAlignmentCenter];
label.opaque=NO;
label.backgroundColor=[UIColor clearColor];
label.textColor = [UIColor blackColor];
UIFont *font = [UIFont boldSystemFontOfSize:20];
label.font = font;
[label setText:[NSString stringWithFormat:@"%d", row]];
return label;
}
</pre>
Source

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview