Add image into navigation bar
When a item is added to favorites. I would like to indicate that it has been successfully added to the user by having a image of a star to fade in, into the navig开发者_高级运维ation bar in place of the right bar button. How can I do this?
Any help will be appreciated! Thanks
You can customize your right bar button item using custom button.
//custom back button
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(-2, 0, 52, 30)];
UIBarButtonItem *btnItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = btnItem;
[btnItem release];
精彩评论