Im trying to give a background for an image view only as white. Following is my code.
dataArray = [[NSMutableArray alloc] init];
[dataArray addObject:@"Knowledge"];
[dataArray addObject:@"Client"];
float screenWidth = [UIScreen mainScreen].bounds.size.width;
float pickerWidth = screenWidth * 3 / 4;
float xPoint = screenWidth / 2 - pickerWidth / 2;
pickerView = [[UIPickerView alloc] init];
pickerView.transform = CGAffineTransformMakeScale(1, 1);
[pickerView setDataSource: self];
[pickerView setDelegate: self];
[pickerView setFrame: CGRectMake(xPoint, 200.0f, pickerWidth, 200.0f)];
pickerView.showsSelectionIndicator = YES;
[pickerView selectRow:2 inComponent:0 animated:YES];
UIImageView *imageview = [[UIImageView alloc]
initWithFrame:CGRectMake(30, 20, 300, 400)];
[imageview setImage:[UIImage imageNamed:@"logo.png"]];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
[imageview setBackgroundColor: [UIColor whiteColor]];
[self.view addSubview:imageview];
[self.view addSubview: pickerView];
Im facing two problems while doing so,
Set pickerview's background color like,
pickerView.backgroundColor = [UIColor lightGrayColor]; //desired color
hope this will help :)