UIView动画私有api演示

AppDelegate.m文件中设置根控制器

RootViewController.m主代码

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    UIView * myview = [[[NSBundle mainBundle] loadNibNamed:@"test" owner:nil options:nil] lastObject];
    myview.frame = CGRectMake(60, 100, 200, 200);
    myview.tag = 2014;
    [self.view addSubview:myview];
    
    UIView *sub1 = [[UIView alloc] initWithFrame:myview.bounds];
    sub1.backgroundColor = [UIColor yellowColor];
    [myview addSubview:sub1];
    [sub1 release];
    UIView *sub2 = [[UIView alloc] initWithFrame:myview.bounds];
    sub2.backgroundColor = [UIColor redColor];
    [myview addSubview:sub2];
    [sub2 release];
    
    
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //获得一个动画对象
    CATransition *animation = [CATransition animation];
    //设置动画时间
    animation.duration = 1;
    //设置动画速率
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    
    /*
     animation.type = @"cube"             //立方体效果
     animation.type = @"suckEffect"       //收缩效果,如一块布被抽走
     animation.type = @"oglFlip"          //上下翻转效果
     animation.type = @"rippleEffect"     //滴水效果
     animation.type = @"pageCurl"         //向上翻一页
     animation.type = @"pageUnCurl"       //向下翻一页
     */
    //设置动画类型
    animation.type = @"pageCurl";
    
    //设置动画子类型
    animation.subtype = kCATransitionFromTop;
    
    
    
    UIView *myView = [self.view viewWithTag:2014];
    
    [myView.layer addAnimation:animation forKey:@"animation"];
    [myView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值