Search code examples
iphoneiosios7uipickerview

How to set the background color of UIPickerView on iOS 7 using SDK 7?


How to set the background color of UIPickerView on iOS 7 using SDK 7 and use a standard picker on iOS 5 and 6? It's transparent by default on iOS 7.


Solution

  • I have added UIView under UIPickerView with code:

    CGRect framePickerView = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 216);
    pickerView = [[[UIView alloc] initWithFrame:framePickerView] autorelease];
    pickerView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:pickerView];
    [pickerView addSubview:picker];
    

    instead the code:

    [self.view addSubview:picker];