大佬教程收集整理的这篇文章主要介绍了ios – 在动画制作时更新视图的帧,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; animation.duration = 100.0; animation.path = self.animationPath.CGPath; [view.layer addAnimation:animation forKey:@"animation"];
工作正常,但是,当尝试检测在屏幕上移动的对象上的触摸时,现在会失败:
- (BOOL)poinTinside:(CGPo@R_674_10185@point withEvent:(UIEvent *)event { for (UIView* subview in self.subviews ) { if ( [subview hitTest:[self convertPoint:point toView:subview] withEvent:event] != nil ) { [self handleTap]; return YES; } } return NO; }
它失败了,因为视图的帧不再与它在动画时在屏幕上的明显位置相同.如何让poinTinside与正在设置动画的视图一起使用?
#import "ViewController.h" @interface ViewController () @property (weak,nonatomiC) IBOutlet AnimatableView *animableView; @end @implementation ViewController - (void)animateAlongPath { UIBezierPath * path = [UIBezierPath bezierPathWithRect:self.view.frame]; CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; animation.duration = 10; animation.path = path.CGPath; animation.removedOnCompletion = NO; animation.fillmode = @"kCAFillmodeForWARDs"; [self.animableView.layer addAnimation:animation forKey:@"animation"]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view,typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBACtion)animate:(id)sender { [self animateAlongPath]; } -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint LOCATIOn = [touch LOCATIOnInView: [touch view]]; CALayer * SELEctedlayer = (CALayer*)[self.animableView.layer.presentationLayer hitTest:LOCATIOn]; if(SELEctedlayer != nil) NSLog(@"touched"); else NSLog(@"dont touched"); } @end
我希望这可以帮助你
以上是大佬教程为你收集整理的ios – 在动画制作时更新视图的帧全部内容,希望文章能够帮你解决ios – 在动画制作时更新视图的帧所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。