UILabel

作者: CaptainRoy | 来源:发表于2019-07-15 02:03 被阅读0次
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let label = UILabel(frame: CGRect(x: 100.0, y: 100.0, width: 100.0, height: 30.0))
        label.textColor = UIColor.red
        label.backgroundColor = UIColor.orange
        label.textAlignment = NSTextAlignment.center
        label.shadowColor = UIColor.gray // 阴影颜色
        label.shadowOffset = CGSize(width: -5.0, height: 5.0)
        label.font = UIFont.systemFont(ofSize: 15.0)
        /*
         byWordWrapping // Wrap at word boundaries, default
         byCharWrapping // Wrap at character boundaries
         byClipping // Simply clip
         byTruncatingHead // Truncate at head of line: "...wxyz"
         byTruncatingTail // Truncate at tail of line: "abcd..."
         byTruncatingMiddle // Truncate middle of line:  "ab...yz"
         */
        label.lineBreakMode = NSLineBreakMode.byTruncatingMiddle
        label.adjustsFontSizeToFitWidth = true
        
        label.text = "swift 语言 是一本很好的语言"
        self.view.addSubview(label)
        
    }

}

相关文章

网友评论

      本文标题:UILabel

      本文链接:https://www.haomeiwen.com/subject/hvowkctx.html