ACBurk
ACBurk

Reputation: 4428

Create a UIButton like the App Buttons on the Springboard (Home Screen)

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.

Upvotes: 0

Views: 1750

Answers (2)

jessecurry
jessecurry

Reputation: 22116

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.

Upvotes: 1

Malaxeur
Malaxeur

Reputation: 6043

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.

Upvotes: 1

Related Questions