Ios 在圆形UIImageView中压缩图像
我正在制作一张个人资料照片 我已经在故事板上添加了一个UIImageView(比如userImageView),并在我的swift文件中添加了以下代码Ios 在圆形UIImageView中压缩图像,ios,swift,uiimageview,Ios,Swift,Uiimageview,我正在制作一张个人资料照片 我已经在故事板上添加了一个UIImageView(比如userImageView),并在我的swift文件中添加了以下代码 self.userImageView.layer.borderWidth = 10 self.userImageView.layer.borderColor = UIColor.white.cgColor self.userImageView.layer.cornerRadius = self.userImageView.frame.height
self.userImageView.layer.borderWidth = 10
self.userImageView.layer.borderColor = UIColor.white.cgColor
self.userImageView.layer.cornerRadius = self.userImageView.frame.height/2
self.userImageView.clipsToBounds = true
但当试图从相机或相册中添加图像时,图像会被压缩
我也尝试过调整图像的大小,但是图像还是被压缩了
我做错了什么?在故事板内容模式中是“方面填充”或“适合”,然后单击剪辑以限制其帮助以适合图像视图边界中的图像在故事板内容模式中是“方面填充”或“适合”,然后单击剪辑以限制其帮助以适合图像视图边界中的图像将
内容模式设置为aspectFill
将您的contentMode
设置为aspectFill
FYI:“并单击要绑定的剪辑”与self.userImageView.clipsToBounds=true
;)仅供参考:“并单击要绑定的剪辑”与self.userImageView.clipsToBounds=true
;)