美文网首页
Label两边或者上下设置间距

Label两边或者上下设置间距

作者: 超级疯小肛 | 来源:发表于2017-09-06 16:24 被阅读0次

    overridefunctextRect(forBounds bounds:CGRect, limitedToNumberOfLines numberOfLines:Int) ->CGRect{

    varrect =super.textRect(forBounds:UIEdgeInsetsInsetRect(bounds,edges) , limitedToNumberOfLines: numberOfLines)

    rect.origin.x-=edges.left;

    rect.origin.y-=edges.top;

    rect.size.width+=edges.left+edges.right;

    rect.size.height+=edges.top+edges.bottom;

    returnrect

    }

    overridefuncdrawText(in rect:CGRect) {

    super.drawText(in:UIEdgeInsetsInsetRect(rect,edges))

    }

    相关文章

      网友评论

          本文标题:Label两边或者上下设置间距

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