How to achieve UIButton / UILabel 'padding' in iPhone app

前端 未结 10 2228
挽巷
挽巷 2021-01-31 13:40

I\'ve got various views in my iPhone application that require padding e.g a custom UIButton with text aligned left, and a UILabel with a background color.

This may be a

10条回答
  •  渐次进展
    2021-01-31 13:59

    I'm trying to achieve a similar thing, that is 'pad' a UILabel. I've been trying to implement the solution that Toby posted above, but can't seem to find where this needs to go. The UILabel I'm working with is aligned left - is that what's causing the issue?

    I've tried using this in viewDidLoad, and even in a subclass of UILabel in the method:

    - (CGRect)textRectForBounds:(CGRect)bounds
         limitedToNumberOfLines:(NSInteger)numberOfLines 

提交回复
热议问题