[英]How do I draw a circle UIView that acts like one with UICollisionBehavior?
在我的应用程序中,我正在绘制一个基本视图,然后我尝试使用CAShapeLayer来绕过它的角落,但是UICollisionBehavior仍然会像它是一个绘制的正方形一样做出反应。
这是我的代码示例
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:UIRectCornerAllCorners
cornerRadii:radiiSize];
// Mask the container view’s layer to round the corners.
CAShapeLayer *cornerMaskLayer = [CAShapeLayer layer];
[cornerMaskLayer setPath:path.CGPath];
self.containerView.layer.mask = cornerMaskLayer;
self.containerView.layer.allowsEdgeAntialiasing = YES;
只需这样做而不是使用UIBezierPath
self.containerView.layer.cornerRadius = [Radius is half the height/width];
self.containerView.clipsToBounds = YES;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.