views:

806

answers:

2

I have been trying to figure this out but have yet to come to a solid conclusion. I would like to create a UIButton and have it look like the buttons on the home screen, with the picture and text below it. I know Apple took away the UIGlassButton so the 3d'ish look can't be programmed but I am mainly wondering about the position of the elements.

How can this be done programmatically.

+1  A: 

If you don't want the text clickable too, you can just create a wrapper class for both a UIButton and a UILabel that automagically positions both of the elements the way you want.

Malaxeur
True, but I am more curious if they (Apple) are manipulating the UIButton's Title's frame and repositioning it.
ACBurk
+1  A: 

You'll want to create a view, in the view you create you'll have two subviews, a UIImageView and a UILabel(maybe these could be readonly properties).

#import <QuartzCore/QuartzCore.h> to get access to the layer property's corner radius. Call [[imageView layer] setCornerRadius: 5.0]; to get the rounded corner appearance without having to modify all of the images you use.

This view can then be placed anywhere and the ImageView and Label will be positioned relative to one another.

Your view can derive from UIControl if you'd like it to be clickable as a whole, otherwise you can use a UIButton in place of the UIImageView.

jessecurry