custom nav bar buttons that use system icons, or image icons
i'm trying to figure out how to make custom nav bar buttons that use system icons, or image icons. i followed the tutorial below on how to set a custom nav bar background, and create custom text buttons, and now i'd like 开发者_开发问答to create buttons like the ones in the tutorial but w/ icons instead of text.
http://idevrecipes.com/2010/12/13/wooduinavigation/
does anyone know how to create custom nav bar buttons with icons?
thanks!
The tutorial is making a UIBarButtonItem object using initWithCustomView:. Basically you can use this to make a button with a custom image. All you have to do is just to create a view with the custom view and pass it as the argument of initWithCustomView:.
Or, more easily, create a UIImage object containing your custom image, and create a UIBarButtonItem object using initWithImage:target:action instead, for example,
UIBarButtonItem *newBarButton = [[UIBarButtonItem alloc] initWithImage: yourImage
target: self
action: @selector(buttonPressed) ];
self.navigationItem.leftBarButtonItem = newBarButton;
[newBarButton release];
精彩评论