加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

UIlabel设置背景为圆形

发布时间:2020-12-14 02:19:14 所属栏目:百科 来源:网络整理
导读:直接对label的cornerRadius进行设置 var text = UILabel(frame: CGRectMake( 10 , 30 ,UIScreen .mainScreen () .bounds .size .width - 20 , 200 )) text .text = "背景为圆形 " text .backgroundColor = self .view .backgroundColor text .textColor = UI

直接对label的cornerRadius进行设置

var text = UILabel(frame: CGRectMake(10,30,UIScreen.mainScreen().bounds.size.width - 20,200))
        text.text = "背景为圆形 "
        text.backgroundColor = self.view.backgroundColor
        text.textColor = UIColor.whiteColor()
        text.font = UIFont.systemFontOfSize(22)
        text.textAlignment = NSTextAlignment.Center
        label.layer.cornerRadius = label1.bounds.size.width/2
        self.view.addSubview(text)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读