我需要一些图像随机出现在屏幕上,然后开始移动,并检测结束移动。我如何得到这个?我的意思是检测结束移动UIView?检测越界屏幕
这些我的代码:
imageNames = @[@"some_array_picture"];
image = [[NSMutableArray alloc] init];
for (int i = 0; i < imageNames.count; i++) {
[image addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
leftX = arc4random_uniform(6) + 10;
leftY = arc4random()%500;
rightX = arc4random_uniform(220) + 20;
rightY = arc4random()%500;
tempX = rightX;
tempY = rightY;
animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(rightX, rightY, 75, 57.5)];
animationImageView.animationImages = image;
animationImageView.animationDuration = 1;
[self.view addSubview:animationImageView];
[self.view sendSubviewToBack:animationImageView];
[animationImageView startAnimating];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.0f];
animationImageView.frame = CGRectMake(leftY, leftY, animationImageView.frame.size.width, animationImageView.frame.size.height);
[UIView commitAnimations];
,因为我需要在运动结束水平旋转,有这样的代码:
animationImageView.transform = CGAffineTransformScale(animationImageView.transform, -1.0, 1.0);
没有流畅的动画在这里,在我的例子animationImageView移动平滑(( – monroe
MB应使用在屏幕边界检测碰撞? – monroe