圆形图像变成钻石而不是圆形-Swift 3 [英] Circular Image Becoming a Diamond Not Circle - Swift 3

查看:93
本文介绍了圆形图像变成钻石而不是圆形-Swift 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试创建圆形图像,但是由于某种原因,它一直被输出为菱形.这是我的代码:

I have been trying to create a circular image but for some reason it has been outputting as a diamond. This is my code:

override func viewDidLoad() {
    displayEmailFullNameImage()

    self.editProfilePictureImage.layer.cornerRadius = editProfilePictureImage.frame.size.width / 2
    self.editProfilePictureImage.clipsToBounds = true
    self.editProfilePictureImage.contentMode = .scaleAspectFill

}

照片上的我的约束

我尝试了以下解决方案:

I have tried the following solution:

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    profilePic.layer.cornerRadius = profilePic.frame.width / 2
    profilePic.clipsToBounds = true
}

但是这也不起作用.

这是图像的外观:

任何帮助将不胜感激.

推荐答案

您的问题可能是由您添加到imageView中的某些约束引起的.尝试仅添加4个约束,1个用于固定宽度,1个用于固定高度,1个用于前导空间,1个用于顶部空间,如下面的屏幕截图所示:

Your problem it is probably caused by some constraints you have added to your imageView. Try adding only 4 constraints, 1 for fixed width, 1 for fixed height, 1 for leading space and 1 for top space as you can see at the screenshot below:

这篇关于圆形图像变成钻石而不是圆形-Swift 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆