For UIButton i was using first UIButtonTypeCustom now i want to change it to RoundedRect but when i change UIButtonTypeCustom to UIButtonTypeRoundedRect it shows RoundedRect in white instead of color specified for it and plus it shows edges of rect buttonframe in back of roundedrect button. So i want to know how to fix this thing.
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[myButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
myButton.frame = CGRectMake(0, 0, 60, 30);
[myButton setTitle:@"Done" forState:UIControlStateNormal];
myButton.backgroundColor = [UIColor colorWithHue:1.0/12 saturation:2.0/3 brightness:4.0/10 alpha:1.0];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:myButton];
[[self navigationItem] setLeftBarButtonItem:button animated:YES];
Thanks for help.
Mmm… I afraid it is not possible to change the backgroundColor of your
UIButtonif it isUIButtonTypeRoundedRect.My suggestion is to create a
UIButtonTypeCustomand change its layer to mimic aUIButtonTypeRoundedRect.Try this code: