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

Swift学习之UILabel基本用法

发布时间:2020-12-14 07:11:04 所属栏目:百科 来源:网络整理
导读:UILabel的常用属性 直接上代码: import UIKitclass ViewController: UIViewController { override func viewDidLoad() { super .viewDidLoad () //定义一个label let myLabel : UILabel = UILabel (frame: CGRectMake( 0 , 0 , 200 , 50 )); //设置label的

UILabel的常用属性

直接上代码:

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //定义一个label
        let myLabel : UILabel = UILabel(frame: CGRectMake(0,0,200,50));

        //设置label的背景色
        myLabel.backgroundColor = UIColor.yellowColor()

        //设置layer 可以用此属性来防止子元素大小溢出父元素,如若防止溢出为true
        myLabel.layer.masksToBounds = true

        //设置label的圆角半径
        myLabel.layer.cornerRadius = 5

        //设置label的text
        myLabel.text = "

欢迎来我的个人博客,希望多多赐教:Coding24h编程无休止

(编辑:李大同)

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

    推荐文章
      热点阅读