views:

22

answers:

1

I've been coding with the iPhone SDK for nearly a year now and managed, up til now, to avoid Core Graphics. My question might therefore look quite simplistic.

I need to implement a class that resembles a real-world 'folder tab'. Here's a mockup ..

two example tabs

I've been getting by with UILabel, and have tried to subclass it, implementing a drawRect method to put the sloped sides on the label with a clipping path ... although this does nothing. I suspect the drawing is already done by this point.

Am I better off subclassing UIView and doing it all myself, or is there anything to be gained from UILabel?

Your clues are most welcome,

M.

A: 

Subclass UIView and use drawRect with CG to draw the text and background, that will be the least restrictive way of doing it. You can use the NSString method drawInRect for the text drawing, and sizeWithAttributes or sizeWithFont to calculate CG rect size.

Ben