Avoid UIDatePicker transparency in iOS7

Midhun Raj picture Midhun Raj · Oct 9, 2013 · Viewed 18.7k times · Source

i just upgraded my app to iOS7 and found that date picker is transparent. It looks like I can see everything which is behind the date picker. How can I avoid this?

I tried to place date picker in another view. But still, its transparent. How can I avoid transparency of UIDatePicker? I've tried this link 1: can I change the font color of the datePicker in iOS7? but it didn't work. Thanks in advance.

Edit : I've added a UIDatePicker to a view named whiteborderview.

whiteborderview.backgroundColor = [UIColor whiteColor];

whiteborderview.alpha = 1.0;

[whiteborderview addSubview:dtPkrStart] 

and I got output like this

transparent datepicker

but still its transparent.

Edit2

I used this code and now its looking better than previous one

[UIView appearanceWhenContainedIn:[UITableView class], [UIDatePicker class], nil].backgroundColor = [UIColor colorWithWhite:1 alpha:1];

dtPkrStart.backgroundColor = [UIColor blackColor];

The date picker appearence changed like this date picker new look

Answer

Maul picture Maul · Oct 9, 2013

Just change background color of your date picker

datepicker.backgroundColor = [UIColor yourcolor];