Objective C:UIBarButtonItem 中的图像未正确显示
我创建了一个要包含在栏按钮项目中的新图像,如下所示
但是,当我尝试将图像添加到 UIBarButtonItem (如下面的代码所示)
UIBarButtonItem *newQuestionButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"doneButton_text"] style:UIBarButtonItemStyleBordered target:self action:@selector(displayNewQuestion)];
我得到以下结果
我能做什么显示实际颜色条形按钮中原始图像中的文本?
I have created a new image to be included in a barbutton item as seen below
However, when I try to add the image to the UIBarButtonItem (as seen in code below)
UIBarButtonItem *newQuestionButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"doneButton_text"] style:UIBarButtonItemStyleBordered target:self action:@selector(displayNewQuestion)];
I get the following result
What can I do to display the actual color of the text in the original image in the barbutton?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它显示为白色的原因是因为仅使用图像中的 alpha 值来创建栏按钮图像。您提供的任何图像都会根据
alpha 值
转换为具有白色阴影
的图像。必须修改图像以符合iOS 人机界面指南
:您可以在此处找到文档:
人机界面指南
The reason why it shows as
white
is because onlyalpha values
in the image are used to create the bar button image. Whatever image you provide is converted into a image withshades of white
, based on thealpha values
. The image must be modified to conform to theiOS Human Interface Guidelines
:You can find the docs here:
Human Interface Guidelines