0

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.

ACBurk
  • 4,418
  • 4
  • 34
  • 50

2 Answers2

1

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
  • 5,973
  • 1
  • 36
  • 34
  • True, but I am more curious if they (Apple) are manipulating the UIButton's Title's frame and repositioning it. – ACBurk Nov 04 '09 at 16:26
1

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
  • 22,068
  • 8
  • 52
  • 44
  • Also check out my answer if you would also like an overlay image effect just like the Apple Springboard. http://stackoverflow.com/questions/2692958/reproduce-springboards-icon-shine-with-webkit/4637318#4637318 – gotnull Jan 09 '11 at 02:51