标签:
#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
标签:
原文地址:http://www.cnblogs.com/YuanYe1/p/4593980.html