我总是设置UINavigationBars
的backgroundImages
,但我从来没有弄清楚如何设置后退按钮的backgroundImage
UINavigationBar
。
我怎样才能做到这一点?
最佳答案
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0,0,36,30);
[button setBackgroundImage:[UIImage imageNamed:@"backgroundImage.png"] forState:UIControlStateNormal];
//[button setTitle:@" Back" forState:UIControlStateNormal];
//[button.titleLabel setFont:[UIFont boldSystemFontOfSize:11]];
[button addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
[self.navigationItem setLeftBarButtonItem:barButtonItem];
关于iphone - 自定义导航栏后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312688/