【发布时间】:2017-05-28 17:07:14
【问题描述】:
【问题讨论】:
-
“寄宿生”到底是什么意思?
-
在代码中显示你的尝试。
-
uiimageview 是显示图片。你不应该覆盖它!使用 UIView 执行自定义绘图!请展示你的尝试!
标签: ios objective-c iphone uibezierpath
【问题讨论】:
标签: ios objective-c iphone uibezierpath
创建一个 UIView(尺寸为正方形),添加角半径 = 其边的 1/2 倍。
现在将 UIImageView 作为子视图添加到此 UIView。
由于图像是圆形的,因此解决问题的更简单方法是在 UIVIew 中添加圆角半径。
下面是我使用的代码:
let circleView: UIView = UIView(frame: CGRect(x: 0,
y: 0,
width: 100,
height: 100))
circleView.center = view.center
circleView.backgroundColor = .lightGray
circleView.layer.cornerRadius = 50
view.addSubview(circleView)
let imageView: UIImageView = UIImageView(frame: CGRect(x: 0,
y: 0,
width: 100,
height: 100))
imageView.image = UIImage(named: "F8FIs.png")
circleView.addSubview(imageView)
请注意,为了清晰起见,我在圆形视图中添加了浅灰色。
这是它的外观截图:
【讨论】: