更改 UIBarButtonSystemItemCancel 的颜色 [英] Change color of UIBarButtonSystemItemCancel

查看:19
本文介绍了更改 UIBarButtonSystemItemCancel 的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 UIBarButtonSystemItemCancel,它的颜色设置为导航栏的颜色.但是,在照片应用程序中,取消"按钮显示为蓝色背景.请问如何将 UIBarButtonSystemItemCancel 设置为蓝色背景?

If I use the UIBarButtonSystemItemCancel, it's color is set to that of the navigation bar. However, in the Photos App, the "Cancel" button is shown with a blue background. How can I also set the UIBarButtonSystemItemCancel to have a blue background please?

推荐答案

您可以将图像用作按钮图像

your can use image as button image as

UIImage *buttonImage = [UIImage imageNamed:@"image.png"];

//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];


//create a UIBarButtonItem with the button as a custom view
//UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

[button addTarget:self action:@selector(clickActionItem:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button ];




self.navigationItem.rightBarButtonItem = rightBarButtonItem;

这篇关于更改 UIBarButtonSystemItemCancel 的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆