Why does a custom UIButton image does not resize in Interface Builder?

前端 未结 10 1210
你的背包
你的背包 2020-12-24 00:45

Why does a custom UIButton image not resize with the button?

I set its view mode to Scale to Fill in Interface Builder, but unlike a UIImageView image, it d

10条回答
  •  臣服心动
    2020-12-24 01:46

    Just do (From Design OR From Code):

    From Design

    1. Open your xib OR Storyboard.
    2. Select button
    3. Inside Attribute Inspector (Right side) > In "Control" section > select last 4th option for both Horizontal and Verical.

    [For Point#3: Change Horizontal and vertical Align to UIControlContentHorizontalAlignmentFill and UIControlContentVericalAlignmentFill]

    From Code

    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill; button.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;

提交回复
热议问题