码迷,mamicode.com
首页 > 其他好文 > 详细

[Label] 文字前距离

时间:2015-08-27 18:24:05      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

class UILabelOverride: UILabel {
    
    override func textRectForBounds(bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
        var rect = super.textRectForBounds(bounds, limitedToNumberOfLines: numberOfLines)
        rect.origin.x = CGFloat(10)
        return rect
    }
    override func drawTextInRect(rect: CGRect) {
        let aRect = self.textRectForBounds(rect, limitedToNumberOfLines: self.numberOfLines)
        super.drawTextInRect(aRect)
        
    }
}

 重写这两个方法之后就可以实现

 

[Label] 文字前距离

标签:

原文地址:http://www.cnblogs.com/baaingSheep/p/4764033.html

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