그래서 fallingBall
이라는 UIView가 현재 theBlockView
이라는 UIView와 잘 충돌합니다. 이 충돌을 감지하기 위해 CGRectIntersectsRect(theBlockView.frame, fallingBall.frame)
을 사용하고 있습니다.Cocoa iOS 충돌이있는 서클로 사각형 만들기
그게 전부예요. 그래서 지금은 내 fallingBall
을 실제로 둥글게하고 싶습니다. theBlockView
의 꼭지점을 반올림하고 싶습니다. 이렇게하려면 다음 코드를 사용했습니다.
//round top right-hand corner of theBlockView
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:theBlockView.bounds
byRoundingCorners:UIRectCornerTopRight
cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = theBlockView.bounds;
maskLayer.path = maskPath.CGPath;
theBlockView.layer.mask = maskLayer;
//round the fallingBall view
[[fallingBall layer] setCornerRadius:30];
그러나 멋지고 둥근 것처럼 보이지만 뷰는 여전히 사각형입니다. 제 질문은 : 어떻게하면 CGRectIntersectsRect
을 모양처럼 보이게 할 수 있습니까? 동일하게 작동하지만 충돌을 감지하기 위해 뷰의 알파를 사용하는 함수가 있습니까?
시간 내 주셔서 감사합니다.
알았어, 팁 주셔서 감사합니다! –