Home > DeveloperSection > Forums > How to set background image into UIPickerView in iOS?
Alex Leblois
Alex Leblois

Total Post:67

Points:471
Posted on    January-27-2016 5:19 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 610  View(s)
Rate this:
I have created an iPhone application. In our application I used UIPickerView controller, I want to know that is it possible to change the background of UIPickerView!
Please guide me how to do it Or can we make UIPickerView skin transparent?


Tarun Kumar

Total Post:210

Points:1614
Supported
Posted on    January-27-2016 5:21 AM

Yes, of course we can change the background of UIPickerView Controller.
First of all create a UIView which will be used as background of UIPickerView and after we will add this view as subview of picker view, like this:

UIView *backgroundViewForPickerView = [[UIView alloc]
                                  initWithFrame:CGrectMake(0,0,150,60)];
[backgroundViewForPickerView setBackgroundColor: [UIColor colorWithPatternImage:
                                  [UIImage imageNamed:@"BackgroundView.png"]]];
[[[pickerView subViews] objectAtIndex:2] addSubview: backgroundViewForPickerView];

I hope it will be helpful for you. thank you.


Modified On Jan-27-2016 05:24:36 AM

Don't want to miss updates? Please click the below button!

Follow MindStick