zoukankan      html  css  js  c++  java
  • IOS动画(动画调用方式)

    IOS动画(动画调用方式)


    第一种:UIView 代码块调用

    _demoView.frame = CGRectMake(0, SCREEN_HEIGHT/2-50, 50, 50);
    [UIView animateWithDuration:1.0f animations:^{
        _demoView.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT/2-50, 50, 50);
    } completion:^(BOOL finished) {
        _demoView.frame = CGRectMake(SCREEN_WIDTH/2-25, SCREEN_HEIGHT/2-50, 50, 50);
    }];
    

    第二种:UIView [begin commit]模式

    _demoView.frame = CGRectMake(0, SCREEN_HEIGHT/2-50, 50, 50);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0f];
    _demoView.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT/2-50, 50, 50);
    [UIView commitAnimations];
    

    第三种:使用Core Animation中的类

    CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"position"];
    anima.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, SCREEN_HEIGHT/2-75)];
    anima.toValue = [NSValue valueWithCGPoint:CGPointMake(SCREEN_WIDTH, SCREEN_HEIGHT/2-75)];
    anima.duration = 1.0f;
    [_demoView.layer addAnimation:anima forKey:@"positionAnimation"];
  • 相关阅读:
    C#调用C++ ---参数传递
    Retained Mode Versus Immediate Mode
    mind map in latex
    vk example
    基本环境
    [转]ld 和 ld.gold 和 ld.bfd
    [转] c++11 int&& 右值引用
    [转] c++11列表初始化
    [转] c++ const, volatile, mutable用法
    [转] c++11 模板元编程
  • 原文地址:https://www.cnblogs.com/sunyanyan/p/5279535.html
Copyright © 2011-2022 走看看