x轴旋转:

CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
theAnimation.duration=;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];
 
y轴旋转:

CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
theAnimation.duration=;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

z轴旋转:

CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
theAnimation.duration=;
theAnimation.removedOnCompletion = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
[yourView.layer addAnimation:theAnimation forKey:@"animateTransform"];

以上缩放是以view的中心点为中心缩放的,如果需要自定义缩放点,可以设置卯点:
//中心点

[yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

//左上角

[yourView.layer setAnchorPoint:CGPointMake(, )];

//右下角

[yourView.layer setAnchorPoint:CGPointMake(, )];

可设参数:

theAnimation.repeatCount = 0;
theAnimation.autoreverses = NO;

旋转的另一种实现:(以下代码绕z轴旋转180度)

    [self.topViewController.view.layer setAnchorPoint:CGPointMake(0.5, 0.5)];
[self.topViewController.view.layer setTransform:CATransform3DMakeRotation(, , , )];
[UIView animateWithDuration: delay:0.0f options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn animations:^{
[self.topViewController.view.layer setTransform:CATransform3DMakeRotation(3.1415926, , , )];
} completion:^(BOOL finished) {
}]; 
 

ios layer 动画-(transform.rotation篇)的更多相关文章

  1. iOS开发——动画编程Swift篇&(三)CATransition动画

    CATransition动画 // MARK: - CATransition动画 // /* 动画样式 */ // let kCATransitionFade: NSString! //翻页 // l ...

  2. iOS开发——动画编程Swift篇&(五)CAKeyframeAnimation

    CAKeyframeAnimation //CAKeyframeAnimation-关键针动画 @IBAction func cakFly() { let animation = CAKeyframe ...

  3. iOS开发——动画编程Swift篇&(四)CABasicAnimation动画

    CABasicAnimation动画 //CABasicAnimation-不透明度 @IBAction func cabOpacity() { let animation = CABasicAnim ...

  4. ios layer 动画

    #import "ViewController.h" @interface ViewController (){    CALayer *_l1;//定义能够全局使用    CAL ...

  5. iOS开发——动画总结OC篇&所有常用动画总结

    所有常用动画总结 先来装下B,看不懂没关系,其实我也看不懂-

  6. iOS开发——动画编程Swift篇&(二)UIView转场动画

    UIView转场动画 // MARK: - UIView动画-过度动画 var redView:UIView? var blueView:UIView? // enum UIViewAnimation ...

  7. iOS开发——动画编程Swift篇&(一)UIView基本动画

    UIView基本动画 // MARK: - UIView动画 ------------------------------------- // MARK: - UIView动画-淡入 @IBActio ...

  8. iOS 动画基础总结篇

    iOS 动画基础总结篇   动画的大体分类(个人总结可能有误) 分类.png UIView 动画 属性动画 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 ...

  9. iOS开发——图形编程OC篇&粘性动画以及果冻效果

    粘性动画以及果冻效果 在最近做个一个自定义PageControl——KYAnimatedPageControl中,我实现了CALayer的形变动画以及CALayer的弹性动画,效果先过目: 先做个提纲 ...

随机推荐

  1. hdu.1254.推箱子(bfs + 优先队列)

    推箱子 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submis ...

  2. Mac Pro 安装 Sublime Text 2.0.2,个性化设置,主题 和 插件 收藏

    1.到官网下载安装包 http://www.sublimetext.com/2 2.附注册码一枚 ----- BEGIN LICENSE ----- Andrew Weber Single User ...

  3. WPF:自定义路由事件的实现

    路由事件通过EventManager,RegisterRoutedEvent方法注册,通过AddHandler和RemoveHandler来关联和解除关联的事件处理函数:通过RaiseEvent方法来 ...

  4. .NET Core Preview

    .NET Core Preview 这是很容易上手使用.NET Core在您选择的平台上. 你只需要一个命令行,一个文本编辑器和10分钟的时间. 原文链接:https://www.microsoft. ...

  5. 如何在IE8设置透明背景

    background:rgba(0,0,0,0.5);filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#7F00000 ...

  6. js刷新页面的几种方法

    history.go(0) location.reload() location=location location.assign(location) document.execCommand('Re ...

  7. Linux之编译需要的文件变化时刻

  8. 剑指Offer 数值的整数次方

    题目描述 给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方.   思路: 要考虑边界,0,负数   AC代码: class Solution ...

  9. 校赛E题递归形式

    #include<stdio.h> #include<string.h> using namespace std; typedef long long ll; ][]; ,,, ...

  10. 百度地图API 海量点 自定义添加信息

    <!--添加百度地图--> <script type="text/javascript" src="http://api.map.baidu.com/a ...