ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 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];


    댓글