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 barb开发者_运维问答utton?
The reason why it shows as white
is because only alpha values
in the image are used to create the bar button image. Whatever image you provide is converted into a image with shades of white
, based on the alpha values
. The image must be modified to conform to the iOS Human Interface Guidelines
:
- Use the PNG format.
- Use pure white with appropriate alpha.
- Do not include a drop shadow.
- Use anti-aliasing.
- If you decide to add a bevel, be sure that it is 90° (to help you do this, imagine a light source positioned at the top of the icon).
- For toolbar and navigation bar icons, create an icon that measures about 20 x 20 pixels.
- For tab bar icons, create an icon that measures about 30 x 30 pixels.
You can find the docs here:
Human Interface Guidelines
精彩评论