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动画小记




  • 相关阅读:
    懂得拐弯,是人生大智慧!
    人心如落叶
    人生聚散,一切随缘!
    35岁以后你还能干嘛?
    人品好,自带光芒
    有一种心境,叫顺其自然
    304. Range Sum Query 2D
    303. Range Sum Query
    301. Remove Invalid Parentheses
    297. Serialize and Deserialize Binary Tree
  • 原文地址:https://www.cnblogs.com/xiaouisme/p/2363308.html
Copyright © 2011-2022 走看看