views:

58

answers:

1

Has anyone worked out a way of getting system buttons into a UISegmentedControl (a UIBarButtonSystemItemAdd, for example)?

If I can't work it out, I'll probably have to extract the system images somehow but it seems wrong, and I'd be surprised if that's how Apple did their segmented control for navigating up and down emails messages in their email client. [actually yes they do, there are no system buttons for up and down]

Probably involves subclassing? thanks if anyone out there can give a Java programmer some tips...

A: 

Hi Eric! You can't add a UIBarButtonItem to a UISegmentedControl. It's really frustrating, I know. I wanted to do that on my own as well. UIBarButtonItem isn't a subclass of UIView, you can add it to the UISegmentedControl.

You can do it with a custom image, like you have mentioned right above. The other method it to create a button using quartz 2d, but that's a lot more complex than just adding a image. You would have to subclass UIControl (or UIButton if you have need of additional functionalities) and draw the whole button manually (or in this case just the "+" sign). I'd recommend you to add a image, it's much easier.

But if you're interested in drawing custom UIBarButtonItems, you take a look a the Project "Three20", you'll find it at github. It was pretty helpful for me getting used to draw custom UIBarButtonItems.

burki