In iOS 9.3 habe ich eine quadratische UIImageView (zB 200x200), und ich versuche, mit cornerRadius einen UIImage (1x1 Pixel) zuzuordnen, und UIImageView wird zu einem Kreis. Ich denke, das Problem kam von UIImageView beim Rendern.Wie UIImageView in iOS 9.3 Rendering ein 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;
Wenn ich contentMode ändern ScaleAspectFill oder ScaleToFill, oder die Größe des UIImage (2x2) zu ändern, oder iOS-Version unter 9.3, funktioniert es wie ich erwartet hatte.
http://i.imgur.com/kM36GPW.png
Das Projekt: download the sample projec
Rot: Tatsächlicher Ergebnis. Grün: Erwartet.
Kann jemand den Grund dafür erklären? Vielen Dank.
set photoImageView.clipsToBounds = YES; –