zoukankan      html  css  js  c++  java
  • UIView的动画

    一种方法是利用封装了CATransition的UIView类方法来实现,这方法简单但效果少。

        //把子视图从父视图里删除的动画效果
    [UIView beginAnimations:@"animation_" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    UIViewController * coming = [[UIViewController alloc] init];
    UIViewController * going = [[UIViewController alloc] init];
    coming.view = self.view.superview;
    going.view = self.view;

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];

    [coming viewWillAppear:YES];
    [going viewWillDisappear:YES];
    [going.view removeFromSuperview];
    [going viewDidDisappear:YES];
    [coming viewDidAppear:YES];

    [UIView commitAnimations];

    [coming release];
    [going release];

    另一种方法是直接利用CATransition,复杂点但效果多些,可控性强,推荐.

    //子视图从父视图里删除的动画效果
    CATransition * animation = [CATransition animation];
    [animation setRemovedOnCompletion:NO];
    [animation setDuration:.25];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
    [animation setType:kCATransitionPush];
    [animation setSubtype:kCATransitionFromRight];

    UIViewController * coming = [[UIViewController alloc] init];
    UIViewController * going = [[UIViewController alloc] init];
    coming.view = self.view.superview;
    going.view = self.view;

    [self.view.superview.layer addAnimation:animation forKey:@"animation_"];

    [coming viewWillAppear:YES];
    [going viewWillDisappear:YES];
    [going.view removeFromSuperview];
    [going viewDidDisappear:YES];
    [coming viewDidAppear:YES];

    [self.view.superview.layer removeAnimationForKey:@"animation_"];

    [coming release];
    [going release];

    再传送两个网址,讲的详细些:

    CATransition的动画效果类型及实现方法

    UIView动画小记




  • 相关阅读:
    git获取远程路径
    qt 运行直接运行exe文件
    QML动画和过度
    学习网络编程的十个步骤
    vs中设置中断
    qt出现警告 Unescaped backslashes are deprecated!解决办法
    git把某此提交运用到某个分支上
    qml学习文档转载
    git远程分支的创建与推送
    qml实现折叠框
  • 原文地址:https://www.cnblogs.com/xiaouisme/p/2363308.html
Copyright © 2011-2022 走看看