zoukankan      html  css  js  c++  java
  • CABasicAnimation 核心动画

    //

    //  ZBMainViewController.m

    //  TestProject

    //

    //  Created by 张先森 on 14/12/5.

    //  Copyright (c) 2014年 zhibin. All rights reserved.

    //

    #import "ZBMainViewController.h"

    @interface ZBMainViewController ()

    @property(nonatomic,strong)CALayer *mylayer;

    @end

    @implementation ZBMainViewController

     bool isopen=NO;

    - (void)viewDidLoad {

        [super viewDidLoad];

        [self InitControls];

    }

    -(void)InitControls{

        CALayer *mylayer=[CALayer layer];

        mylayer.bounds=CGRectMake(0, 0, 100, 100);

        mylayer.backgroundColor=[UIColor yellowColor].CGColor;

        mylayer.position=CGPointMake(100, 100);

        mylayer.anchorPoint=CGPointMake(0, 0);

        mylayer.cornerRadius=10;

        [self.view.layer addSublayer:mylayer];

        self.mylayer=mylayer;

        

    }

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

        if (!isopen) {

            

      

        CABasicAnimation *anim=[CABasicAnimation animation];

        anim.keyPath=@"position";

        anim.duration=10;

        anim.fromValue=[NSValue valueWithCGPoint:CGPointMake(100, 100)];

        anim.toValue=[NSValue valueWithCGPoint:CGPointMake(150, 300)];

        anim.removedOnCompletion=NO;

        anim.fillMode=kCAFillModeForwards;

        [self.mylayer addAnimation:anim forKey:@"move"];

            

            isopen=true;

        }else{

            

             isopen=false;

            [self.mylayer removeAnimationForKey:@"move"];

        

        

        }

    }

    @end

  • 相关阅读:
    JUnitBeforeClass、AfterClass、Before、After示例
    4 jquery中dom操作和事件的实例学习访yahoo邮箱登录框的提示效果
    2 jquery 强大的选择器
    3 jquery对象和dom对象的相互转换
    开博第一篇
    转载notepad++ zendcoding使用
    轻描淡写的日子
    测试
    BPMN中的任务(task)介绍
    Google App Engine正式对Java进行支持
  • 原文地址:https://www.cnblogs.com/zhibin/p/4152244.html
Copyright © 2011-2022 走看看