创建UIButton像在Springboard上的应用程序按钮(主屏幕) [英] Create a UIButton like the App Buttons on the Springboard (Home Screen)

查看:101
本文介绍了创建UIButton像在Springboard上的应用程序按钮(主屏幕)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力想出这一点,但还没有得出一个坚实的结论。我想创建一个UIButton,让它看起来像主屏幕上的按钮,下面的图片和文字。我知道苹果拿走了UIGlassButton,所以3d'ish看起来不能编程,但我主要想知道的元素的位置。



如何做到这一点

解决方案

您将需要创建一个视图,在您创建的视图中将有两个子视图,UIImageView和一个UILabel(可能是只读属性)。



#import< QuartzCore / QuartzCore.h> 以访问图层属性的圆角半径。
调用 [[imageView图层] setCornerRadius:5.0]; 无需修改所有使用的图像即可获得圆角。 b
$ b

这个视图可以放在任何地方,ImageView和Label将相对于彼此放置。



您的视图可以派生自UIControl,如果你想它可作为一个整体,否则你可以使用UIButton代替UIImageView。


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.

解决方案

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.

这篇关于创建UIButton像在Springboard上的应用程序按钮(主屏幕)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆