본문 바로가기
개발노트/iOS

Swift: UIButton 내 이미지 크기 조절하기

by 전지적진영시점 2022. 8. 18.
반응형

개발 환경

---------------------------------

OS : Mac

개발 툴 : xcode

개발 언어 : Swift

xcode version : 14.2

min iOS version : 13.0 

---------------------------------

 

안녕하세요 전진시입니다!

 

UIButton 내 이미지 사이즈를 조절해보겠습니다

이게 기억이 잘 안나! 그래서 정리를 해두려고 합니다.

 

참고로 저는 iOS13.0을 최소버전으로 하여 개발중입니다!

 

 

 

 

 

 

button.setImage(UIImage(named: "qnaremove"), for: .normal)
button.contentVerticalAlignment = .fill
button.contentHorizontalAlignment = .fill
button.imageEdgeInsets = UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2)

 

스토리 보드에서 작업을하면 이미지 사이즈 조절이 어려워 저는 코드로 

버튼 내에 padding을 주어 이미지 사이즈 조절을 했습니다.

 

이상 !

 

https://www.buymeacoffee.com/jinyyyyleeG

 

cloi

Are you sure? Switching to a new level will terminate your current membership. You will no longer have access to this level or its rewards.

www.buymeacoffee.com

 

 

반응형

댓글