#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