Search code examples
iosswiftuibuttonuikituiedgeinsets

iOS System Icons not respecting UIButton's UIImageInsets


I am using iOS's system icons so that I can have a consistent user interface throughout my project. One thing that I've noticed when using these icons is that, even if I set a system icon as the image for a UIButton, it will not grow to fill the size of the button, like normal project images do. For example, if we have a very large UIButton, let's say a height and width of 500, even if the UIButton's image insets's left, top, bottom, and right values are each set to 0 in the interface builder, the system icon being used for the button's image will remain its same small size. enter image description here enter image description here

In fact, the only time that the system icons will respect the interface builder's instructions for image insets is when said insets require that the image make itself smaller.

enter image description here

Does anybody know how to make system icons behave similarly to normal project images with respect to UIButtons' image insets?


Solution

  • check the marks in the picture you can use interface builder. In the attributes inspector on the right-hand side, use the Control section as follows:

    and code you can use in storyboard also as you are already using.