Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私のアプリでは、ユーザーは CALayers のスタックから一番上の CALayer をドラッグできます。
ユーザーがドラッグを停止すると、CALayer は他の CALayer の上にある元の位置に戻ります。CALayer (ドラッグ後) が他の CALayer とオーバーラップしない限り、他の CALayer の下に移動する必要があります。
では、2 つの CALayer がオーバーラップしているかどうかを検出するにはどうすればよいでしょうか?
CALayer のフレーム プロパティは CGRect です。幸いなことに、CGGeometry には次のメソッドがあります。
CGRectIntersectsRect
次のように使用します。
if (CGRectIntersectsRect(myLayer1.frame,myLayer2.frame)) { //code }