I need to put images on add,cancel and back buttons of navigation bar. I have done with add button but not getting for back button.
even with this add button image it shows back blue color custom button.how to set for this?
UIBarButtonItem *addButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bar_add_button.png"]
style:UIBarButtonSystemItemAdd target:self
action:@selector(addNote)];
开发者_如何转开发
// Initialize the UIButton
UIImage *buttonImage = [UIImage imageNamed:@"buttonImage.png"];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setImage:buttonImage forState:UIControlStateNormal];
aButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
// Initialize the UIBarButtonItem
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];
// Set the Target and Action for aButton
[aButton addTarget:self action:@selector(aButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
// Then you can add the aBarButtonItem to the UINavigationBar
...
self.navigationItem.leftBarButtonItem = aBarButtonItem;
// Release buttonImage
[buttonImage release];
精彩评论