iOS 프로젝트 개발 실전-UIImageView 사용 및 이미지 디 스 플레이 모드

현재 우 리 는 iOS 의 Image 컨트롤 을 사용 하여 그림 을 표시 하고 그림 의 표시 모드 를 설정 합 니 다.코드 는 다음 과 같 습 니 다.
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  
  //              ;            ,      ;
  UIImage *image = [UIImage imageNamed:@"img"];
  
  //           ;    UIImageView;
  UIImageView *imgView = [[UIImageView alloc]init];
  //                  ;
  //                ,         UIImageView   ;
  imgView.frame = CGRectMake(10, 100, 300, 500);
  imgView.backgroundColor = [UIColor yellowColor];
  [imgView setImage:image];
  
  [self.view addSubview:imgView];
  
  //       ;
  /*
   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,
   
   */
  //    ;
  //  :UIViewContentModeScaleToFill        ;
  /*
   UIViewContentModeScaleToFill:        ;
   UIViewContentModeScaleAspectFit:       ,       ;
   UIViewContentModeScaleAspectFill:       ,       ;
   */
  imgView.contentMode =  UIViewContentModeScaleAspectFill;
  
}



@end

github 홈 페이지:https://github.com/chenyufeng1991  。여러분 의 방문 을 환영 합 니 다!

좋은 웹페이지 즐겨찾기