您的位置:首页 > 产品设计 > UI/UE

IOS开发(12)之UILabel

2013-04-24 11:07 232 查看

1 前言

UILabel可以给用户显示静态文字,并且设置文字的样式。

2 代码实例

ZYViewController.h:

#import <UIKit/UIKit.h>

@interface ZYViewController : UIViewController

@property(nonatomic,strong) UILabel *myLabel;

@end


ZYViewController.m:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor whiteColor];
//    CGRect labelFrame = CGRectMake(0.0f, 0.0f, 100.0f, 23.0f);
CGRect labelFrame = CGRectMake(0.0f, 0.0f, 100.0f, 50.0f);
self.myLabel = [[UILabel alloc] initWithFrame:labelFrame];
self.myLabel.numberOfLines = 3;//分三行
self.myLabel.text = @"Archy is Studying IOS 5 Programming";//label的文字
self.myLabel.font = [UIFont boldSystemFontOfSize:14.0f];//字体样式
self.myLabel.center = self.view.center;//UILabel控件居中
[self.view addSubview:self.myLabel];

}


运行结果:



3 结语

以上就是UILabel的简单介绍,希望对大家有所帮助。

Demo实例下载:http://download.csdn.net/detail/u010013695/5294606
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息