현재 2 개의 콘텐츠 모드를 동시에 설정할 수 없습니다. 하지만 이미지의 크기와 중심이 모두 필요합니다. 어떻게해야합니까?센터 및 가로 세로 맞춤 이미지
@property (weak, nonatomic) IBOutlet UIView *windowOut;
self.windowOut.layer.borderColor = [UIColor redColor].CGColor;
self.windowOut.layer.borderWidth = 3.0f;
UIImage *face = [UIImage imageNamed:@"face.png"];
UIImageView* imageView = [[UIImageView alloc] initWithFrame:self.windowOut.frame];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.contentMode = UIViewContentModeCenter;
[imageView setImage:face];
[self.windowOut addSubview:imageView];
이 이미지는 상기 코드 결과 :이 이미지 결과가
때 "imageView.contentMode = UIViewContentModeCenter; "주석 :
EDIT : 이 이미지는 두 콘텐츠 모드를 모두 주석 처리 한 결과입니다.
어쨌든 UIViewContentModeScaleAspectFit은 이미지를 중앙에 배치하지 않습니까? –
아니 괴상한 이유로 오른쪽 이동 % 10 오른쪽 – Esqarrouth
이미지를 추가했습니다 ... – Esqarrouth