UIViewAnimationTransition视图180度翻转效果

#import "TurnViewController.h"

@implementation TurnViewController

- (void)dealloc
{
[super dealloc];
}



-(void)doScale:(id)sender{
UIView
*centerView = [self.view viewWithTag:100];
UIViewAnimationTransition trans
= UIViewAnimationTransitionFlipFromLeft;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:
1.0f];
[UIView setAnimationTransition:trans forView:centerView cache:YES];
[centerView exchangeSubviewAtIndex:
0 withSubviewAtIndex:1];
[UIView commitAnimations];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];

CGRect rect
= CGRectMake(30, 50, 250, 300);
UIView
*centerView = [[UIView alloc] initWithFrame:rect];
[centerView setBackgroundColor:[UIColor whiteColor]];
[centerView setTag:
100];
[self.view addSubview:centerView];
[centerView release];

rect
= CGRectMake(0, 0, 250, 300);
UIView
*bView = [[UIView alloc] initWithFrame:rect];
[bView setBackgroundColor:[UIColor blackColor]];
[centerView addSubview:bView];
[bView release];

rect
= CGRectMake(10, 10, 100, 30);
UITextView
*textView1 = [[UITextView alloc] initWithFrame:rect];
[textView1 setText:
@"反面内容"];
[textView1 setBackgroundColor:[UIColor yellowColor]];
[bView addSubview:textView1];
[textView1 release];

rect
= CGRectMake(120, 250, 100, 30);
UIButton
*bButton = [[UIButton alloc] initWithFrame:rect];
[bButton setTitle:
@"翻到正面" forState:UIControlStateNormal];
[bButton setBackgroundColor:[UIColor redColor]];
[bButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
[bView addSubview:bButton];
[bButton release];


rect
= CGRectMake(0, 0, 250, 300);
UIView
*aView = [[UIView alloc] initWithFrame:rect];
[aView setBackgroundColor:[UIColor whiteColor]];
[centerView addSubview:aView];
[aView release];

rect
= CGRectMake(10, 10, 100, 30);
UITextView
*textView = [[UITextView alloc] initWithFrame:rect];
[textView setText:
@"正面内容"];
[textView setBackgroundColor:[UIColor yellowColor]];
[aView addSubview:textView];
[textView release];

rect
= CGRectMake(120, 250, 100, 30);
UIButton
* aButton = [[UIButton alloc] initWithFrame:rect];
[aButton setTitle:
@"翻到背面" forState:UIControlStateNormal];
[aButton.titleLabel setTextColor:[UIColor whiteColor]];
[aButton setBackgroundColor:[UIColor blackColor]];
[aButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:aButton];
[aButton release];






rect
= CGRectMake(140, 400, 50, 50);
UIButton
* cButton = [[UIButton alloc] initWithFrame:rect];
[cButton setTitle:
@"" forState:UIControlStateNormal];
[cButton.titleLabel setTextColor:[UIColor whiteColor]];
[cButton setBackgroundColor:[UIColor blueColor]];
[cButton addTarget:self action:@selector(doScale:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:cButton];
[cButton release];


}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

转载于:https://www.cnblogs.com/wujian1360/archive/2011/08/29/2158576.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值