2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOSメモ UIImageView 比率合わせ

Last updated at Posted at 2016-06-09

typedef enum {
UIViewContentModeScaleToFill, // デフォルト。UIImageViewに最大限広げる
UIViewContentModeScaleAspectFit, // 画像のaspect比を維持し、ちょうどはいるようにする
UIViewContentModeScaleAspectFill, // 画像のaspect比を維持し、最大限広げる(はみ出した分はカット)
UIViewContentModeRedraw, //like UIViewContentModeScaleToFill
UIViewContentModeCenter, //画像サイズをそのままに、真ん中を表示
UIViewContentModeTop, //上位置に表示
UIViewContentModeBottom, //下位置に表示
UIViewContentModeLeft, //左位置に表示
UIViewContentModeRight, //右位置に表示
UIViewContentModeTopLeft, //左上位置に表示
UIViewContentModeTopRight, //右上位置に表示
UIViewContentModeBottomLeft, //左下位置に表示
UIViewContentModeBottomRight, //右下位置に表示
} UIViewContentMode;

**サンプル**

  • (void)viewDidLoad {
    [super viewDidLoad];
    self.userIconImageView = [[UIImageView alloc] initWithImage:self.userIconImage];
    self.userIconImageView.frame = CGRectMake(self.sideWidth + 10, self.navigationController.navigationBar.frame.size.height
    + [[UIApplication sharedApplication] statusBarFrame].size.height + 30, 65, 65);
    self.userIconImageView.userInteractionEnabled = YES;
    self.userIconImageView.tag = 1;
    self.userIconImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.userIconImageView.clipsToBounds = YES; //写真をアイコンの形にする
    self.userIconImageView.layer.cornerRadius = 32.5;
    [self.view addSubview:self.userIconImageView];
    }
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?