dwery
dwery

Reputation: 1116

UIBarButtonItem clone

I have an UIButton subclass and I need its look to be identical to an UIBarButtonItem when placed on the classic blue tinted navigation bar.

UIBarButtonItem

The UIBarButtonItem has a border with a kind-of gradient, being darker at the top and blue-ish at the bottom, which I suspect it's done with some alpha trick. The bottom looks recessed too.

There's also some overlay which makes the button a little bit darker and even more when in the selected state.

Can anyone help?

Upvotes: 1

Views: 837

Answers (3)

Tuyen Nguyen
Tuyen Nguyen

Reputation: 4479

You can use Three20 library,
specially have a look at sample TTCatalog app.

Look at the source file "StyleTestController.m"

https://github.com/facebook/three20/blob/master/samples/TTCatalog/Classes/StyleTestController.m

I'm sure you'll find your answer here.

Cheers,

Upvotes: 0

amattn
amattn

Reputation: 10065

The short answer is that you are going to have to spend some time learning how to draw gradients and shadows in Core Graphics.

The relevant documentation is called "Quartz 2D Programming Guide".

After you learn how to draw shadows and gradients, you are going to have to spend quite a bit of time zoomed in comparing what you are drawing vs what the button looks like.

You didn't ask, but this is what I would do:

Subclass UIBarButtonItem and add your custom functionality in there. Let UIBarButtonItem draw itself.

Upvotes: 1

David
David

Reputation: 14404

It might be easier for you just to use a photoshopped image. Use the image for your button. This way you don't have to worry about custom drawing code.

Upvotes: 0

Related Questions