views:

704

answers:

1

I am using a UISegmentedControl with images that is in a UIBarButtonItem, which is itself in a UIToolbar. If I use an image for a "normal" UIBarButtonItem, a nice shadow effect is automatically applied. However, the same does not automatically apply to images in UISegmentedControl's that belong to UIBarButtonItem's. I was thinking of subclassing UISegmentedControl to apply this shadow effect, but I'm not quite sure where to start with the graphics API's to achieve this. I'm guessing I'd need to override:

  • (void)drawRect:(CGRect)rect;

but beyond that, I'm not sure where to go.

Anyone have any suggestions for a starting point?

Another option would be to apply the shadow effect directly to the source images. However, my skills in the icon / graphics department are not up to par to achieve this either. Any suggestions for tools that might help me achieve this effect? Maybe via ImageMagick or something?

Thanks in advance for any help!

A: 

I can get you part way there. I had to set the content mode to UIViewContentModeRedraw which calls redraw when the frame changes size.

I'm still muddling through getting my custom drawing done right and will follow up when I get it right.

[self setContentMode:UIViewContentModeRedraw];
[self setFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width+1, self.frame.size.height)];
Oldmicah