我想在imageView中显示一张图片,就像图片联系人(在一个圆圈中)一样,但当我尝试显示时,imageView会重新缩放他的大小,而这不能在圆圈中正确显示
image.layer.borderWidth=1.0
image.layer.masksToBounds=false
image.layer.borderColor=UIColor.whiteColor().CGColor
image.layer.cornerRadius=image.frame.size.height/2
image.clipstobunds=true
我想这样表现:
但我明白了:
如何将图像调整为UIImageView大小以显示为圆形
谢谢
这是我在应用程序中使用的解决方案:
var-image:UIImage=UIImage(名为:“imageName”)
imageView.layer.borderWidth=1.0
imageView.layer.masksToBounds=false
imageView.layer.borderColor=UIColor.whiteColor().CGColor
imageView.layer.cornerRadius=image.frame.size.width/2
imageView.clipsToBounds=true
Swift 4.0
让image=UIImage(名为:“imageName”)
imageView.layer.borderWidth=1.0
imageView.layer.masksToBounds=false
imageView.layer.borderColor=UIColor.white.cgColor
imageView.layer.cornerRadius=image.frame.size.width/2
imageView.clipsToBounds=true