Control — select an image from an album or camera to make a portrait

As a rule, first:

Control -- select an image from an album or camera to make a portrait
selects pictures to make pictures
Control -- select an image from an album or camera to make a portrait
user denied authorization prompt

Usage

- (void) viewDidLoad {[super viewDidLoad]; / / the minimum configuration needs only two lines of code to achieve all the functionality of MGAvatarImageView *avatarIV = [[MGAvatarImageView alloc] initWithFrame:CGRectMake (100, 100, 200, 200)]; [self.view addSubview: avatarIV]; / / the following appearance attribute is optional, can be set up, do not set the default value of avatarIV.delegate = self [UIColor; avatarIV.navItemColor = redColor]; blackColor = [UIColor avatarIV.navImageColor / / default / / redColor]; the default is blackColor avatarIV.navBarBackgroundColor = MatchaColor; whiteColor = [UIColor avatarIV.sheetTitleColor / / default / / redColor]; the default is blackColor avatarIV.imageType = MGAvatarImageViewTypeAvatar; / / the default is MGAvatarImageView TypeAvatar avatarIV.statusBarStyle = UIStatusBarStyleLightContent;} / / default to UIStatusBarStyleDefault - MGAvatarImageViewDelegate - #pragma mark (void) imageView: (MGAvatarImageView * imageView) didSelectImage: (UIImage * image) {/ / if needed, this method can be implemented, the results will be transferred after the user selected, cropped picture}

brief introduction

  • The entire control has only 2 files: MGAvatarImageView.h, MGAvatarImageView.m, which is extremely simple to use and requires at least 2 lines of code.
  • Directly inherited from UIImageView, it can be used as a UIImageView, such as setting rounded corners, shading, and using the SDWebImaged framework.
  • Support pictures cut into head (square), also support direct display of the original size of the picture (avatarIV.imageType = MGAvatarImageViewTypeOriginScale)
  • Checking whether to authorize or deny authorization is actually UIImagePickerController’s own.

Source code transfer gate