Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- #import "ContainerViewController.h"
- #import "LeftSettingViewController.h"
- #import "RoundViewController.h"
- @implementation ContainerViewController
- @synthesize subViewControllers, isOpeningLeftSettingVC;
- - (void)viewDidLoad {
- [super viewDidLoad];
- LeftSettingViewController *leftVC = [[LeftSettingViewController alloc] initWithNibName:@"LeftSettingViewController" bundle:nil];
- RoundViewController *roundVC = [[RoundViewController alloc] initWithNibName:@"RoundViewController" bundle:nil];
- subViewControllers = @[roundVC, leftVC];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- isOpeningLeftSettingVC = NO;
- RoundViewController *roundVC = (RoundViewController*)subViewControllers.firstObject;
- [self addChildViewController:roundVC];
- roundVC.view.frame = self.view.frame;
- [self.view addSubview:roundVC.view];
- [roundVC didMoveToParentViewController:self];
- }
- -(void)transitionLeftSettingVC{
- if (!isOpeningLeftSettingVC) {
- RoundViewController *roundVC = (RoundViewController*)subViewControllers.firstObject;
- LeftSettingViewController *leftVC = (LeftSettingViewController*)subViewControllers.lastObject;
- [self addChildViewController:leftVC];
- leftVC.view.frame = CGRectMake(-self.view.bounds.size.width/3, 0, self.view.bounds.size.width/3, self.view.bounds.size.height);
- [UIView animateWithDuration:0.5 delay:0.2 options:UIViewAnimationOptionLayoutSubviews animations:^{
- leftVC.view.frame = CGRectMake(0, 0, self.view.bounds.size.width/3, self.view.bounds.size.height);
- roundVC.view.frame = CGRectMake(self.view.bounds.size.width/3, 0, self.view.bounds.size.width * 2/3, self.view.bounds.size.height);
- [self.view addSubview:leftVC.view];
- } completion:^(BOOL finished) {
- [leftVC didMoveToParentViewController:self];
- }];
- isOpeningLeftSettingVC = YES;
- }else{
- RoundViewController *roundVC = (RoundViewController*)subViewControllers.firstObject;
- LeftSettingViewController *leftVC = (LeftSettingViewController*)subViewControllers.lastObject;
- [leftVC willMoveToParentViewController:nil];
- [UIView animateWithDuration:0.5 delay:0.2 options:UIViewAnimationOptionLayoutSubviews animations:^{
- roundVC.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
- leftVC.view.frame = CGRectMake(-self.view.bounds.size.width/3, 0, self.view.bounds.size.width/3, self.view.bounds.size.height);
- } completion:^(BOOL finished) {
- [leftVC removeFromParentViewController];
- [leftVC.view removeFromSuperview];
- }];
- isOpeningLeftSettingVC = NO;
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement