码迷,mamicode.com
首页 > 编程语言 > 详细

swift-UILabel

时间:2016-05-16 17:23:22      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

 1 // Mark: 2. 创建label
 2     private func creatLabel(title: NSString)->UILabel{
 3                 /// 创建label
 4         let titleL = UILabel(frame: CGRectMake(100, 64, 200, 60))
 5         
 6         titleL.text = title as String
 7         titleL.textColor = UIColor.redColor()
 8         titleL.backgroundColor = UIColor.yellowColor()
 9         titleL.layer.cornerRadius = 10.0
10         titleL.layer.masksToBounds = true
11         titleL.textAlignment = NSTextAlignment.Center
12         titleL.font = UIFont.systemFontOfSize(16.0)
13         // 阴影
14         titleL.shadowColor = UIColor.cyanColor()
15         titleL.shadowOffset = CGSizeMake(-2, 2)
16         // 省略方式
17         titleL.lineBreakMode = NSLineBreakMode.ByTruncatingTail
18 //        titleL.adjustsFontSizeToFitWidth = true
19         titleL.numberOfLines = 2
20         
21         // 富文本
22         let attr = NSMutableAttributedString(string: "NSMutableAttributedStringNSMutableAttributedStringNSMutableAttributedString")
23         
24         attr.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(25.0), range: NSMakeRange(0, 6))
25         attr.addAttribute(NSForegroundColorAttributeName, value: UIColor.purpleColor(), range: NSMakeRange(7, 15))
26         titleL.attributedText = attr
27         
28         self.view.addSubview(titleL)
29         return titleL;
30     }

 

swift-UILabel

标签:

原文地址:http://www.cnblogs.com/guangleijia/p/5498319.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!