【转】iOS中两个视图的翻转

转:http://blog.csdn.net/answer__3/article/details/48412655
找到好久才找到这个效果。

翻转动画
1.建立两个视图,hidden是yes和no
2.将视图加在view上,给按钮一个属性,

  • (void)BtnAction:(UIButton *)btn{

    //
    UIView *rightView = self.navigationItem.rightBarButtonItem.customView;
    //
    UIButton *btn1 = (UIButton *)[rightView viewWithTag:100];

    UIButton *btn2 = (UIButton *)[rightView viewWithTag:101];

    UIViewAnimationTransition transframe = btn2.hidden?
    UIViewAnimationTransitionFlipFromLeft:
    UIViewAnimationTransitionFlipFromRight;

    [self _transView:transframe WithView:rightView];
    [UIView commitAnimations];
    btn1.hidden = !btn1.hidden;
    btn2.hidden = !btn2.hidden;
    //

[self _transView:transframe WithView:self.view];//视图翻转和按钮公用一个方式

_tableview.hidden = !_tableview.hidden;
_postview.hidden = !_postview.hidden;

}

  • (void)_transView:(UIViewAnimationTransition )trans WithView:(UIView *)view{

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1 ];
    [UIView setAnimationTransition:trans
    forView:view
    cache:YES];

[UIView commitAnimations];

}

你可能感兴趣的:(【转】iOS中两个视图的翻转)