Search code examples
iphoneuibuttonuibarbuttonitemquartz-2duicontrol

Custom UIBarButtonItem with quartz


How can I draw a button with quartz that has exactly the same style as a UIBarButtonItem. The button should be able to show different colors. I downloaded the Three20 project, but this project is really complex, you'd need a lot of time to overlook the whole framework. I just want to draw a custom UIBarButtonItem.

Thanks for help.


Solution

  • If you are using the Three20 library, I guess TTButton's "toolbarButton" style is what you want. TTButton is a sub-class of UIButton, but it allows you to apply styles just like using css while creating a webpage.

    To create a button like a UIBarButtonItem, just call

    [TTButton buttonWithStyle:@"toolbarButton:" title:@"Title"]
    

    You may need to retain it since the button is an auto-release object.