How to set background image into UIPickerView in iOS?

Total Post:67

Points:471
 2290  View(s)
Ratings:
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?
  1. Post:214

    Points:1642
    Re: How to set background image into UIPickerView in iOS?

    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
  1. Post:1

    Points:7
    Re: How to set background image into UIPickerView in iOS?

    hey guys

    i want to add images to picker view , and i am real new to coding

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!