label swift

var label = UILabel(frame: CGRectMake(10, 20, 300, 100))
label.text = "《Swift语言实战入门》"
self.view.addSubview(label)

    label.textColor = UIColor.whiteColor()
    label.backgroundColor = UIColor.blackColor()

    label.textAlignment = NSTextAlignment.Right
    //文字阴影
    label.shadowColor = UIColor.grayColor()
    label.shadowOffset = CGSizeMake(-5, 5)//偏移量,x轴y轴
    //字体设置
    label.font = UIFont(name: "Zapfino", size: 20)
    //文字的省略方式
    label.text = "《Swift语言实战入门》这是一本很不错的书呦"
    label.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle;
    //文字的自动调整
    label.adjustsFontSizeToFitWidth = true
    //多行字符串
    label.numberOfLines = 2
posted @ 2016-12-16 23:58  乱笙歌  阅读(154)  评论(0编辑  收藏  举报