UI之label基本使用

来源:互联网 发布:移动软件开发方向 编辑:程序博客网 时间:2024/06/07 05:36

UILabel->UIView->UIResponder->NSObject//继承关系
生命周期:
当程序加载的时候
将要进入后台
已经过入后台
将要进入前台
已经进入前台
程序退出
self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor=[UIColor whiteColor];
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, 20, 100, 20)];
label.text=@”我是标签1”;
label.backgroundColor=[UIColor redColor];
label.textColor=[UIColor redColor];
label.font=[UIFont systemFontOfSize:20];
label.alpha=0.8;
label.font=[UIFont boldSystemFontOfSize:20];//字体加粗
label.textAlignment=NSTextAlignmentCenter;//居中
label.shadowColor=[UIColor blueColor];//阴影颜色
label.shadowOffset=CGSizeMake(-5, 5);//阴影偏移量
label.font=[UIFont italicSystemFontOfSize:14];//倾斜字体
label.numberOfLines=3;//默认1,0为不限制
label.lineBreakMode=NSLineBreakByTruncatingMiddle;//设置行文字截断方式;
label.adjustsFontSizeToFitWidth=YES;//根据lable大小改变文字大小,直到显示全部内容。
viewWithTag拿到tag值
NSTimer * _timer=[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(func) userInfo:nil repeats:YES];//创建定时器
_timer.fireDate=[NSDate distantFuture];//拿到将来的时间
_timer.fireDate=[NSDate distantPast]//拿到过去的时间;

0 0