开发者

How do I show my own image on a UIToolbar's UIBarButtonItem

开发者 https://www.devze.com 2023-01-10 19:14 出处:网络
I have seen variations of this question before in the forum, but I did not quite understand the solutions.

I have seen variations of this question before in the forum, but I did not quite understand the solutions.

I have a regular ViewController that hosts a UIToolbar at the bottm. The toolbar has several UIBarbuttonItems for example one of them has: Style: Plain Identifier: Custom Title: Stop

Now I want it to display an ima开发者_StackOverflow中文版ge I heve provided So I add Image: MyImage.png

Now I get an opaque gray rectangle instead of my image.

Are there specific requirements from images that are to be show on a UIBarButtonItem? Size? Opcity? other?


  1. Set the UIBarButtonItem Identifier to Custom.
  2. Add a UIButton as a subview of the UIBarButtonItem.
  3. Set the UIButton Type to Custom.
  4. Set the UIButton Image to your image file.

The specific requirement for the image is that it be toolbar-compatible, in that the alpha channel holds the pertinent pixel data, and the RGB values are simply a grayscale for blending-- likely white or black.

More info: http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html

0

精彩评论

暂无评论...
验证码 换一张
取 消