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)
}
}
网友评论