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

  • 相关阅读:
    Abp集成Swagger的最佳实践
    ELK 集中日志分析 windows部署实战
    nuget国内镜像的解决办法
    nginx+Memcached 缓存设计
    OpenSSL windows 下编译
    HTTPS 双向认证构建移动设备安全体系
    ASP.NET vNext on CentOS 7
    XF custom render 各平台实现类
    Xamarin.Forms 简介
    【开篇】认识网络和传输,架构
  • 原文地址:https://www.cnblogs.com/zhibin/p/4152244.html
Copyright © 2011-2022 走看看