I am using iOS 5.1 with StoryBoards. I want to change the tint of the standard page curl button, but I don't seem to be able too.
The button is on a View Controller and is a pushed View Controller of a Navigation Controller. The toolbar is inferred, as I changed the tint on the Navigation Controller. The toolbar appears in the desired color.
My viewDidLoad method is as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
// adjust the color of the curl button
if (self.curlButton) {
NSMutableArray * toolbarItems = [self.toolbarItems mutableCopy];
[toolbarItems removeObject:self.curlButton];
UIColor *barColor = self.navigationController.toolbar.tintColor;
UIBarButtonItem *newPageCurl = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPageCurl target:self.curlButton.target action:self.curlButton.action];
newPageCurl.tintColor = barColor;
NSLog(@"%@", newPageCurl.tintColor);
[toolbarItems addObject:newPageCurl];
self.toolbarItems = toolbarItems;
}
}
self.curlButton
is an outlet for the page curl button that is configured in Interface Builder.
I already tried just setting the tint in self.curlButton
, which is initially nil, but that didn't work, the button was the same blue tint.
Some of the answers on SO say you have to create a new button programmatically, which is what I am trying here.
I have verified that the barColor
contains the correct color. I commented out the removeObject
line and that correctly produced two curl buttons, but both were blue.
The NSLog verifies that the newPageCurl
button has the correct tint set.
I tried doing all this in viewDidAppear
instead, in case the toolbar needed to be displayed first, but the button was still blue and didn't use the new tint.