【发布时间】:2015-10-08 08:20:41
【问题描述】:
代码如下:
override func awakeFromNib() {
super.awakeFromNib()
profilePic.frame = CGRectMake(10, 7, 40, 40)
profilePic.layer.cornerRadius = profilePic.frame.width/2
profilePic.layer.masksToBounds = true
contentView.addSubview(profilePic)
}
我一直用这段代码把图片做成圆形,现在变成圆角矩形了,怎么解决?
[edit] 这个方法每次我需要时都对我有用,但是现在我在一个单独的类中为 UITableView 的单元格执行此操作,它不会为图像赋予圆形!
【问题讨论】:
-
使用
image.clipsToBounds = true并尝试 -
不起作用@EICaptain
-
你是否将 maskToBounds 设置为 false 并使用 clipsToBounds