-
UIImageView Image ContentMode (비율)iOS/Objective C 2017. 1. 3. 11:55
//이미지를 중앙 비율을 맞추는것은 contentMode라고 한다
//그에대한 자세한 설명은 http://marines.co.kr/archives/174
//contentMode Enum
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
UIImageView* imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"testImage"]];
[imageView setContentMode:UIViewContentModeScaleAspectFill];
//이미지뷰의 이미지가 center crop된 상태에서 밖으로 튀어나간 이미지를 안보이게 처리해주는 MasksToBounds
[[imageView layer] setMasksToBounds:YES];
'iOS > Objective C' 카테고리의 다른 글
NSTimer가 스크롤링(Scrolling) 할때 작동이 멈춰요 (0) 2017.08.09 아이폰에서만 사용하고싶어요 혹은 아이패드에서만 사용하고싶어요 (0) 2017.08.08 NSString 문자열 나누기 (0) 2017.01.03 NSString 제일 마지막 문자 삭제 (0) 2017.01.03 UIImage Image resize (이미지 비율) (0) 2017.01.03