在iOS 9.3中,我有一个正方形的UIImageView(例如200x200),我尝试用cornerRadius指定一个UIImage(1x1像素),并且UIImageView成为一个圆。我认为这个问题来自于UIImageView的渲染。UIImageView如何在iOS 9.3渲染UIImage?
photoImageView.image = [UIImage imageNamed:@"iphone.jpeg"]; // 1px height x 1 px width
photoImageView.contentMode = UIViewContentModeScaleToFill;
// It can fixed with the below code
// photoImageView.image = [[UIImage imageNamed:@"iphone.jpeg"] stretchableImageWithLeftCapWidth:2 topCapHeight:2];
// photoImageView.contentMode = UIViewContentModeScaleAspectFill;
photoImageView.layer.cornerRadius = 20.0;
photoImageView.layer.masksToBounds = YES;
如果我改变以下9.3 contentMode到ScaleAspectFill或ScaleToFill,或更改的UIImage(2×2)的大小,或iOS版本,它就像我的预期。
http://i.imgur.com/kM36GPW.png
红:真正的结果。 绿色:预计。
有人可以解释它的原因吗?谢谢。
set photoImageView.clipsToBounds = YES; –