//设置原始画面 UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; showView.layer.masksToBounds = YES; showView.layer.cornerRadius = 50.f; showView.layer.backgroundColor = [UIColor redColor].CGColor; [self.view addSubview:showView]; //创建基本动画 CABasicAnimation *basicAnimation = [CABasicAnimation animation]; //设置属性 basicAnimation.keyPath = @"position"; basicAnimation.duration = 4.0f; basicAnimation.fromValue = [NSValue valueWithCGPoint:showView.center]; basicAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(50, 300)]; //设置动画结束位置 showView.center = CGPointMake(50, 300); //添加动画到layer层 [showView.layer addAnimation:basicAnimation forKey:nil];
//设置原始画面
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
showView.layer.masksToBounds = YES;
showView.layer.cornerRadius = 50.f;
showView.layer.backgroundColor = [UIColor redColor].CGColor;
[self.view addSubview:showView];
//创建关键帧动画
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimation animation];
//设置动画属性
keyFrameAnimation.keyPath = @"position";
keyFrameAnimation.duration = 4.0f;
keyFrameAnimation.values = @[[NSValue valueWithCGPoint:showView.center],
[NSValue valueWithCGPoint:CGPointMake(100, 100)],
[NSValue valueWithCGPoint:CGPointMake(50, 150)],
[NSValue valueWithCGPoint:CGPointMake(200, 200)]];
//设置动画结束位置
showView.center = CGPointMake(200, 200);
//添加动画到layer层
[showView.layer addAnimation:keyFrameAnimation forKey:nil];
//设置原始画面
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
showView.layer.masksToBounds = YES;
showView.layer.cornerRadius = 50.f;
showView.layer.backgroundColor = [UIColor redColor].CGColor;
[self.view addSubview:showView];
//创建关键帧动画
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimation animation];
//设置动画属性
keyFrameAnimation.keyPath = @"position";
keyFrameAnimation.duration = 4.0f;
//关键处, 在这里使用的缓动函数计算点路径
keyFrameAnimation.values = [YXEasing calculateFrameFromPoint:showView.center
toPoint:CGPointMake(50, 300)
func:BounceEaseOut
frameCount:4.0f * 30];
//设置动画结束位置
showView.center = CGPointMake(50, 300);
//添加动画到layer层
[showView.layer addAnimation:keyFrameAnimation forKey:nil];
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有