如何在Swift中正确设置imageView在sqContacts中?

编程入门 行业动态 更新时间:2024-10-23 09:40:59
本文介绍了如何在Swift中正确设置imageView在sqContacts中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望将图片显示到imageView中,就像图片联系人一样(在一个圆圈中)但是当我尝试显示这个时,imageView会重新调整他的大小,这在圆圈中无法正确显示..

I want show a picture into imageView like the image contact (in a circle) But when I try show this, the imageView rescale his size and this doesn't show correctly in a circle..

image.layer.borderWidth=1.0 image.layer.masksToBounds = false image.layer.borderColor = UIColor.whiteColor().CGColor image.layer.cornerRadius = image.frame.size.height/2 image.clipsToBounds = true

我希望这样显示:

I want show like this:

但我明白了:

But I get this:

如何将图像调整为UIImageView大小以显示圆圈?

How can do that image resize to UIImageView size to show like circle?

谢谢!

推荐答案

您使用的框架尺寸图像?如果我将框架设置为正方形,我可以得到一个完美的圆圈。

What frame size are you using for image? I can get a perfect circle if I set the frame to be a square.

let image = UIImageView(frame: CGRectMake(0, 0, 100, 100))

更多推荐

如何在Swift中正确设置imageView在sqContacts中?

本文发布于:2023-11-26 20:15:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   如何在   sqContacts   Swift   imageView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!