Label两边或者上下设置间距

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两边或者上下设置间距)