`
119568242
  • 浏览: 428568 次
  • 性别: Icon_minigender_1
  • 来自: 深圳/湛江
社区版块
存档分类
最新评论

[ios]CA animationWIthKeyPath的一些思考

    博客分类:
  • ios
 
阅读更多

使用CABasicAnimation的时候 总会遇到 animationWithKeyPath的情况 keyPath到底是什么呢?

今天查了下文档,大概意思是说使用此动画的对象 的key (也就是这个使用动画的对象能响应个消息)。

其中尝试对backgroundColor进行设置

旋转于放大缩小使用transform

 

补充1:

keypath 是 layer属性 注释说明中含有Animatable的

资料:http://objccn.io/issue-12-4/

资料:http://blog.csdn.net/lvxiangan/article/details/17167827

 

 

//
//  PLLViewController.m
//  LNCAnimation
//
//  Created by liu poolo on 14-5-13.
//  Copyright (c) 2014年 liu poolo. All rights reserved.
//

#import "PLLViewController.h"
#import <QuartzCore/QuartzCore.h>



@interface PLLViewController ()

@end

@implementation PLLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    CALayer *_cl=[[CALayer alloc] init];
    _cl.backgroundColor=[[UIColor grayColor] CGColor];
    _cl.frame=CGRectMake(10, 10, 40, 40);
    _cl.cornerRadius=5.0f;
    
    
    CABasicAnimation *_ca=[CABasicAnimation animationWithKeyPath:@"position"];//对哪个通道进行动画描写
    _ca.fromValue=[NSValue valueWithCGPoint:_cl.position];
    CGPoint toPoint=_cl.position;
    toPoint.x+=100;
    _ca.toValue=[NSValue valueWithCGPoint:toPoint];
    [self.view.layer addSublayer:_cl];
    _ca.autoreverses=YES;
    _ca.duration=1.0f;
    _ca.repeatCount=NSNotFound;

//    [_cl addAnimation:_ca forKey:@"kLayerPLMove"];
    
    
    CABasicAnimation *_caRotato = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
    _caRotato.fromValue = [NSNumber numberWithFloat:0.0f];
    _caRotato.toValue = [NSNumber numberWithFloat:6.0f*M_PI];
    _caRotato.autoreverses=YES;
    _caRotato.duration=10.0f;
    _caRotato.repeatCount=NSNotFound;
    
    CABasicAnimation *_caScaole = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
    _caScaole.fromValue = [NSNumber numberWithFloat:1.0f];
    _caScaole.toValue = [NSNumber numberWithFloat:3.0f];
    _caScaole.autoreverses=YES;
    _caScaole.duration=10.0f;
    _caScaole.repeatCount=NSNotFound;
    
    CABasicAnimation *_caColor=[CABasicAnimation animationWithKeyPath:@"backgroundColor"];
    //animationWithKeyPath后跟随的是CALayer可接受的Key即可 既使用动画的对象的Key
    _caColor.fromValue=(__bridge id)([[UIColor grayColor] CGColor]);
    _caColor.toValue=(__bridge id)([[UIColor redColor] CGColor]);
    
    CAAnimationGroup *_caGroup=[CAAnimationGroup animation];
    [_caGroup setAnimations:[NSArray arrayWithObjects:_ca,_caRotato,_caScaole,_caColor,nil]];
    _caGroup.duration=10.0f;
    _caGroup.repeatCount=NSNotFound;
    _caGroup.autoreverses=YES;
    
    
    [_cl addAnimation:_caGroup forKey:@"GroupKey"];

//    [_cl addAnimation:_caRotato forKey:@"rotatoKey"];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

分享到:
评论

相关推荐

    美团 iOS 客户端的构建思考与实践

    在本文档中,美团大众点评的高级工程师罗泽响分享了关于美团iOS客户端构建过程中的思考和实践经验。文档中提到的关键知识点主要包括了iOS客户端架构的演进、高效开发实践、模块化设计思想、以及持续集成(CI)等关键...

    IOS_CA路由CA认证服务器

    IOS_CA路由CA认证服务器,IOS_CA路由CA认证服务器

    美团 iOS 客户端的构建思考与实践 罗泽响 .pdf

    罗泽响作为美团大众点评的高级工程师,在这份文档中,详细介绍了美团iOS客户端的构建思考与实践,其中包括了iOS客户端构建的关键理念、技术选型、实践过程、优化策略以及未来展望等内容。 首先,文档提到了iOS...

    HBuilderX申请iOS证书在线打包iOS文档.docx

    在申请iOS证书时,需要提供一些信息,包括证书名称、App ID、Bundle ID等。App ID是应用程序的唯一标识符,Bundle ID是应用程序的包名。 二、HBuilderX在线打包流程 HBuilderX提供了在线打包功能,支持开发者在...

    思考Catalyst 3560 IOS

    思考网络设备交换机sw2960的最新的IOS版本

    ios helper用于苹果ios系统的实用工具

    iOS Helper则提供了第三方应用商店的功能,让用户可以更自由地下载和安装应用,包括一些在App Store中无法找到的软件或游戏。 此外,iOS Helper还具备设备清理和性能提升功能。它能深度扫描iOS设备,找出隐藏的垃圾...

    iOS开发中一些手写控件及其相关属性的使用.pdf

    iOS开发中一些手写控件及其相关属性的使用

    iOS动画效果集 CA360.zip

    本资源"iOS动画效果集 - CA360.zip"包含了一系列基于Objective-C编写的`Core Animation`示例,旨在帮助开发者深入理解和运用这个框架。 `Core Animation`并非只是简单的2D动画库,而是通过图层(Layers)和渲染树...

    iOS 真机调试包 iOS 15.1、15.0、14.8、14.7

    在iOS应用开发过程中,真机调试是不可或缺的一个环节。它允许开发者在实际设备上测试应用程序,确保其在不同iOS版本和设备上的兼容性和性能。本文将深入探讨如何使用iOS真机调试包,特别是针对iOS 15.1、15.0、14.8...

    高仿微信,iOS应用开发模板.zip ios 开发模板

    高仿微信,iOS应用开发模板.zip ios 开发模板。高仿微信,iOS应用开发模板.zip ios 开发模板。高仿微信,iOS应用开发模板.zip ios 开发模板。高仿微信,iOS应用开发模板.zip ios 开发模板。高仿微信,iOS应用开发...

    iOS 16.0真机包噢

    iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16真机包iOS 16...

    ios旧版抓包工具ios旧版抓包工具

    ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧版抓包工具ios旧...

    iOS12 真机调试包

    此外,iOS 12引入了一些开发者的新特性,例如增强的Core ML 2,使得机器学习模型的运行速度提升且占用更少的内存;ARKit 2改进了增强现实体验,支持多人共享AR世界;以及SceneKit和SpriteKit的更新,提高了游戏和...

    iOS 15.4真机包呀

    iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS 15.4真机包iOS ...

    斯坦福ios7公开课纸牌源码(stanford ios7)

    7. **iOS7特有功能**:由于源码基于iOS7,可能会用到一些当时的新特性,如扁平化设计、Parallax效果、控制中心(Control Center)集成等。这些特性在源码中会有相应的实现。 8. **Interface Builder与Programmatic ...

    iOS11.2 真机调试包

    此外,对于iOS 11.2版本,开发者需要注意一些特定的API变更、性能优化以及可能出现的兼容性问题。例如,iOS 11引入了新的设计语言(如Stack View)、增强的Core ML框架以及ARKit的更新,这些都是开发者需要关注的...

    iOS9.3.2,iOS10(Xcode_8_beta6)SDK支持xocde5、6

    iOS9.3引入了一些重要的更新,例如Night Shift模式,用于减少屏幕蓝光对眼睛的影响,以及改进的教育功能,提升了用户体验。 接下来,iOS10 SDK则是为了支持iOS10及其更新版本的应用开发。在这个版本中,Apple引入了...

    iOS开发中一些实用的Demo.zip

    iOS开发中一些实用的Demo

    最新IOS17.0真机调试包

    在iOS开发领域,真机调试是开发者不可或缺的功能,它允许程序员在实际设备上测试应用程序,以确保软件在各种硬件配置和系统版本上运行无误。本文将深入探讨“最新iOS 17.0真机调试包”以及与之相关的Xcode、iOS和Mac...

Global site tag (gtag.js) - Google Analytics