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

前端 未结 10 2082
挽巷
挽巷 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 14:14

    To set padding in UIButton text you need to use UIButton's contentEdgeInsets property.

    In Storyboard, to set content inset do following steps:

    1. Select the view controller, then select the UIButton
    2. Go to Utilities Panel (Command + Option + 0) and select Attributes Inspector (Command + Option + 4)
    3. Now select Content in Edge and set Inset as per your requirement (see screenshot)

提交回复
热议问题