mardi 5 juillet 2016

How to set different colours with HEX values in Picker Background

I want to set three different colours to picker view background one for the the background items one for the item which is currently in picker(selected item).How would i do that.

I have hex value of a color(#01445) so i have to set it for picker background. How to set these hex values. And also i have to set this color(#014455) value to the selected item in picker.

myPickerView = [[UIPickerView alloc]init];
myPickerView.dataSource = self;
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;
myPickerView.tag=1;
myPickerView.backgroundColor =[UIColor blueColor];   //set different color here with hex value

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
                               initWithTitle:@"Done" style:UIBarButtonItemStyleDone
                               target:self action:@selector(done:)];


UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:
                      CGRectMake(0, self.view.frame.size.height-
                                 myPickerView.frame.size.height-(self.view.frame.size.width/6.4),self.view.frame.size.width,50)];
[toolBar setBarStyle:UIBarStyleBlackOpaque];

[toolBar setBackgroundColor:[UIColor orangeColor]];  // i have hex value #ff7a03 so i have to set here

NSArray *toolbarItems = [NSArray arrayWithObjects:
                         doneButton, nil];
[toolBar setItems:toolbarItems];

Aucun commentaire:

Enregistrer un commentaire