ios   UILabel

发布时间:2020-07-30 23:49:54 作者:zhaoweizheng66
来源:网络 阅读:300

  
//    UILabel,标签视图,主要用于显示文字
    //UILabel继承于UIView
    
    //1.创建(开辟内存初始化)
    UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 100, 50)];
    //2.设置属性
    userlabel.backgroundColor = [UIColor redColor];
    //设置文本
    userlabel.text = @"登陆";//也可以用set方法[userlabel setText:<#(NSString *)#>]
    //设置字体样式
    //系统字体
    //userlabel.font = [UIFont systemFontOfSize:40];
    //系统字体加粗
    userlabel.font = [UIFont boldSystemFontOfSize:40];//
    //自定义文字样式
    //userlabel.font =[UIFont fontWithName:@"" size:60];
    //设置文本颜色
    userlabel.textColor = [UIColor whiteColor];
    //设置行数,默认是1, o代表无限行
    userlabel.numberOfLines = 0;
    //设置文字对齐方式
    userlabel.textAlignment = NSTextAlignmentCenter;
    //设置文字阴影
//    userlabel.shadowColor = [UIColor grayColor];
//    //设置阴影的偏移,宽度影响左右,高度影响上下
//    userlabel.shadowOffset = CGSizeMake(10, 10);
   //文本大小适应lable宽度
    userlabel.adjustsFontSizeToFitWidth = YES;
    //字体大小, 缩放比率
    userlabel.minimumScaleFactor = 0.5;
    

推荐阅读:
  1. iOS开发:UILabel字号根据屏幕缩放
  2. iOS UILabel设置行高代码解析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

标签 ios uilabel

上一篇:unity3d 右键快速打开文件

下一篇:我和EDAS这两年——阿里巴巴入职两年的小结

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》