Created
August 25, 2013 03:39
-
-
Save xdream86/6331856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)viewDidLoad{ | |
[super viewDidLoad]; | |
UIButton *btnFlip = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | |
btnFlip.frame = CGRectMake(10, 10, 50, 30); | |
[btnFlip setTitle:@"flip" forState:UIControlStateNormal]; | |
[btnFlip addTarget:self action:@selector(flip) forControlEvents:UIControlEventTouchUpInside]; | |
[self.view addSubview:btnFlip]; | |
panel = [[UIView alloc] initWithFrame:CGRectMake(10, 40, 300,300)]; | |
panel.backgroundColor = [UIColor darkGrayColor]; | |
[self.view addSubview:panel]; | |
panelBack = [[UIView alloc] initWithFrame:CGRectMake(10, 40, 280, 200)]; | |
panelBack.tag = 1; | |
panelBack.backgroundColor = [UIColor brownColor]; | |
[panel addSubview:panelBack]; | |
panelFront = [[UIView alloc] initWithFrame:CGRectMake(10, 40, 280, 200)]; | |
panelFront.tag = 2; | |
panelFront.backgroundColor = [UIColor whiteColor]; | |
[panel addSubview:panelFront]; | |
displayingFront = TRUE; | |
} | |
-(void)flip{ | |
[UIView transitionWithView:panel | |
duration:0.5 | |
options:(displayingFront ? UIViewAnimationOptionTransitionFlipFromRight : UIViewAnimationOptionTransitionFlipFromLeft) | |
animations:^{ | |
if (displayingFront) { | |
//panelFront.hidden=TRUE; | |
//panelBack.hidden = FALSE; | |
[panelFront removeFromSuperview]; | |
[panel addSubview:panelBack]; | |
}else{ | |
//panelFront.hidden=FALSE; | |
//panelBack.hidden = TRUE; | |
[panelBack removeFromSuperview]; | |
[panel addSubview:panelFront]; | |
} | |
} | |
completion:^(BOOL finished){ | |
displayingFront = !displayingFront; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment