【问题标题】:Objective C: Image not displayed correctly in UIBarButtonItem目标 C:图像未在 UIBarButtonItem 中正确显示
【发布时间】:2011-08-01 10:49:28
【问题描述】:

我创建了一个要包含在条形按钮项目中的新图像,如下所示

但是,当我尝试将图像添加到 UIBarButtonItem 时(如下面的代码所示)

UIBarButtonItem *newQuestionButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"doneButton_text"] style:UIBarButtonItemStyleBordered target:self action:@selector(displayNewQuestion)];

我得到以下结果

如何在 barbutton 中显示原始图像中文本的实际颜色?

【问题讨论】:

    标签: objective-c ios uiimage uibarbuttonitem


    【解决方案1】:

    之所以显示为white,是因为图片中只有alpha values用于创建条形按钮图片。您提供的任何图像都会根据alpha values 转换为带有shades of white 的图像。图片必须修改为符合iOS Human Interface Guidelines:

    1. 使用 PNG 格式。
    2. 使用带有适当 alpha 的纯白色。
    3. 不要包含投影。
    4. 使用抗锯齿。
    5. 如果您决定添加斜角,请确保它是 90°(为了帮助您做到这一点,请想象一个位于图标顶部的光源)。
    6. 对于工具栏和导航栏图标,创建一个大小约为 20 x 20 像素的图标。
    7. 对于标签栏图标,创建一个大小约为 30 x 30 像素的图标。

    您可以在此处找到文档:

    Human Interface Guidelines

    【讨论】:

    • 感谢您的回复。那么这是否意味着我不能在 uibutton 中将文本颜色从白色更改为灰色?
    • @Zhen 可以,灰色是白色的阴影。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多