PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 6, 2022

[FIXED] How to set image size in UIButton?

 May 06, 2022     image, ios, scale, swift, uibutton     No comments   

Issue

I'm trying to make a clone of decimal pad by stack views and UIButtons. But when I try to make "Backspace" button image inside of it scales to the bounds of button.

How could I make image scale smaller than button itself?


Solution

There may be two options to fix the problem.

  1. Set the content mode to .scaleAspectFit and the image should not go out of the bounds : myButton.imageView?.contentMode = .scaleAspectFit

  2. Adjust the image insets: myLikesButton.imageEdgeInsets = UIEdgeInsetsMake(top, left, bottom, right)



Answered By - Sanket Ray
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing