iPhone dev.
UIButton 이미지 비율 조절하기
홍진표
2012. 12. 1. 08:56
UIImageView의 경우 UIViewContentMode를 interface builder(IB)에서 조절할 수 있다.
(Scale to fit, Aspect fit, Aspect fill, ...)
하지만, UIButton에 이미지를 적용했을 경우 IB에서는 버튼 view 자체의 UIViewContentMode만 변경할 수 있는데, 코드로 다음과 같이 변경하면 된다.
UIButton *button = [[UIButton ...]];
[button.imageView setContentMode:UIViewContentModeScaleAspectFit]
위의 예제는 버튼의 이미지 모드를 Aspect fit으로 변경한 경우이다.