我想完美地裁剪我的UIView的边界,以便像圆一样交互,但无论我如何设置边角半径,遮罩和剪裁到边界,它显示正确,它作为一个方形移动,如你在图像中看到的:

我使用的代码是:
let bubble1 = UIView(frame: CGRectMake(location.x, location.y, 128, 128))
bubble1.backgroundColor = color2
bubble1.layer.cornerRadius = bubble1.frame.size.width/2
bubble1.clipsToBounds = true
bubble1.layer.masksToBounds = true仍然保留视图边缘的问题是什么?
PD:所有的视图都是动态移动的,所以当它移动并相互碰撞时,它会显示这些空白空间,就像一个正方形而不是一个圆形
发布于 2016-04-25 05:33:10
最后,我找到了要实现的东西,就是那个类,而不是UIView:
class SphereView: UIView {
// iOS 9 specific
override var collisionBoundsType: UIDynamicItemCollisionBoundsType {
return .Ellipse
}
}https://stackoverflow.com/questions/36821110
复制相似问题