因此,对于objective-c我是新手,并且我的图像始终在屏幕上上下移动,如果另一个图像触摸或拦截该图像,我将如何编码。这是我已经完成的动画代码,但仍然对如何编写第二部分感到困惑。谢谢你的帮助
动画:
//LINE ANAMATION
layer = line.layer;
CGPoint startPoint = (CGPoint){line.center.x,20};
CGPoint endPoint = (CGPoint){line.center.x, screenSizeY/2};
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.duration = 3.f;
animation.path = thePath;
animation.autoreverses = YES;
animation.repeatCount = INFINITY;
[layer addAnimation:animation forKey:@"position"];
答案 0 :(得分:1)
尝试:
if (CGRectIntersectsRect(self.imageView1.frame, self.imageView2.frame))
{
NSLog(@"Intersected!");
}
else
{
NSLog(@"No intersection :(");
}