在iOS6中,我使用此代码来创建我的UIBarButtonItem: UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@"MyTitle" style:UIBarButtonItemStylePlain target:self action:@selector(actionValidate)]; [validate setTintColo
UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@"MyTitle" style:UIBarButtonItemStylePlain target:self action:@selector(actionValidate)]; [validate setTintColor:[UIColor orangeColor]]; self.navigationItem.rightBarButtonItem = validate;
它在iOS6中运行良好,但在iOS7中,按钮的颜色只有在你推动时才会改变.我该如何解决这个问题?
在iOS7中,如果需要更改navigationBar按钮颜色,则必须为navgationBar设置tintColor,而不是为特定的barButton设置tintColor.navigationController.navigationBar.tintColor = [UIColor orangeColor];
编辑:这适用于iOS7,您需要进行检查:
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; if (systemVersion >= 7.0) { navigationController.navigationBar.tintColor = [UIColor orangeColor] }