我在导航栏中添加了以下内容来自定义我的后退按钮,但图像只是重叠/重复:
http://i.stack.imgur.com/eyzJC.png
- (void)viewWillAppear:(BOOL)animated
{
//take out the label following the button
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
//set image for back button
[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"backButtonImage.png"]];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"backButtonImage.png"]];
self.navigationItem.backBarButtonItem = backButton;
}
它应该是一个朝向左侧的黑色箭头的图像。
在它工作正常之前,但现在它在我模拟它时会这样做。任何见解和帮助将不胜感激。
谢谢
答案 0 :(得分:0)
这应该适合你。
UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom];
back.frame = CGRectMake(0, 0, 50, 44);
back.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[back setImage:[UIImage imageNamed:@"backButtonImage.png"] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: back];
添加功能:
-(void) back
{
[self.navigationController popViewControllerAnimated:YES];
}
答案 1 :(得分:0)
添加此代码
[UINavigationBar appearance].barTintColor = [UIColor colorWithWhite:1.00 alpha:1];
它应该可以解决你的问题。