码迷,mamicode.com
首页 > 移动开发 > 详细

iOS Lable

时间:2015-06-22 22:10:22      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

#import "ViewController.h"

 @interface ViewController ()

 @end

 @implementation ViewController

 - (void)viewDidLoad {

    [super viewDidLoad];

    UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 50)];    //创建标签

    lable.backgroundColor=[UIColor greenColor];     //设置背景颜色

    lable.text=@"Hello World!";     //字体内容

    lable.textColor=[UIColor redColor];   //字体颜色

    lable.font=[UIFont fontWithName:@"" size:25];   //字体和大小

    lable.shadowColor=[UIColor blueColor];  //  阴影的颜色

    lable.shadowOffset = CGSizeMake(4,4);  //shadowOffset阴影偏移,x向右偏移4,y向下偏移4.

    lable.textAlignment = NSTextAlignmentLeft;  // Lable内容的对齐格式

    [self.view addSubview:lable];

       // Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end

Lable常用属性:

@property(nonatomic,copy)   NSString           *text;            // default is nil

@property(nonatomic,retain) UIFont             *font;            // default is nil (system font 17 plain)

@property(nonatomic,retain) UIColor            *textColor;       // default is nil (text draws black)

@property(nonatomic,retain) UIColor            *shadowColor;     // default is nil (no shadow)

@property(nonatomic)        CGSize             shadowOffset;    // default is CGSizeMake(0, -1) -- a top shadow

@property(nonatomic)        NSTextAlignment    textAlignment;   // default is NSTextAlignmentLeft

@property(nonatomic)        NSLineBreakMode    lineBreakMode;   // default is NSLineBreakByTruncatingTail. used for single and multiple lines of text

 

iOS Lable

标签:

原文地址:http://www.cnblogs.com/YuanYe1/p/4593980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!