[英]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.