开发者

UIDate Picker background color [duplicate]

This question already has answers here: How to change UIPicker Color ? iPhone (6 answers) 开发者_运维百科 Closed 8 years ago.

HI I would like to change the background color of the UIDatePicker from the current glossy image to clear just like in this example

UIDate Picker background color [duplicate]

(source: apple.com)

Any ideas how to do that? I tried

datepicker.backgroundColor = [UIColor clearColor];

but it didnt work.


UIDatePicker contains one subview. That subview, in turn, contains 15 other subviews that form UIDatePicker's appearance. The first and the last of them are the background, so to make it transparent just turn them off and set background color of main subview to clearColor:

// create the picker
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 320)];

// add it to some view first
[actionSheet addSubview:datePicker];
[datePicker release];

// clear the background of the main subview
UIView *view = [[datePicker subviews] objectAtIndex:0];
[view setBackgroundColor:[UIColor clearColor]];

// hide the first and the last subviews
[[[view subviews] objectAtIndex:0] setHidden:YES];
[[[view subviews] lastObject] setHidden:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜