@@ -64,6 +64,7 @@ - (id)initWithMenuViewController:(UIViewController *)menuViewController mainView
6464- (void )commonInitialization
6565{
6666 self.animationDuration = kDefaultAnimationDuration ;
67+ self.animationType = TWTSideMenuAnimationTypeSlideOver;
6768
6869 [self addViewController: self .menuViewController];
6970 [self addViewController: self .mainViewController];
@@ -293,7 +294,6 @@ - (void)setMainViewController:(UIViewController *)mainViewController animated:(B
293294 animation.duration = kDefaultAnimationDuration ;
294295 [overlayView.layer addAnimation: animation forKey: @" opacity" ];
295296
296- CGFloat outgoingStartX = CGRectGetMaxX (outgoingViewController.view .frame );
297297 NSTimeInterval changeTimeInterval = kDefaultSwapAnimationDuration ;
298298 NSTimeInterval delayInterval = kDefaultAnimationDelayDuration ;
299299 if (!self.open ) {
@@ -306,10 +306,35 @@ - (void)setMainViewController:(UIViewController *)mainViewController animated:(B
306306 [self .containerView addSubview: incomingViewController.view];
307307
308308 incomingViewController.view .frame = self.containerView .bounds ;
309- incomingViewController.view .transform = CGAffineTransformTranslate (incomingViewController.view .transform , outgoingStartX, 0 .0f );
309+
310+
311+ // Create default animation curve.
312+ UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseInOut;
313+ switch (self.animationType ) {
314+ case TWTSideMenuAnimationTypeSlideOver: {
315+ CGFloat outgoingStartX = CGRectGetMaxX (outgoingViewController.view .frame );
316+
317+ incomingViewController.view .transform = CGAffineTransformTranslate (incomingViewController.view .transform , outgoingStartX, 0 .0f );
318+ break ;
319+ }
320+ case TWTSideMenuAnimationTypeFadeIn:
321+ incomingViewController.view .alpha = .6 ;
322+ options = UIViewAnimationOptionCurveEaseOut;
323+
324+ break ;
325+ }
326+
310327
311328 void (^swapChangeBlock)(void ) = ^{
312- incomingViewController.view .transform = CGAffineTransformIdentity;
329+ switch (self.animationType ) {
330+ case TWTSideMenuAnimationTypeSlideOver:
331+ incomingViewController.view .transform = CGAffineTransformIdentity;
332+ break ;
333+ case TWTSideMenuAnimationTypeFadeIn:
334+ incomingViewController.view .alpha = 1 ;
335+ default :
336+ break ;
337+ }
313338 };
314339
315340 void (^finishedChangeBlock)(BOOL finished) = ^(BOOL finished) {
@@ -330,7 +355,7 @@ - (void)setMainViewController:(UIViewController *)mainViewController animated:(B
330355
331356 [UIView animateWithDuration: changeTimeInterval
332357 delay: delayInterval
333- options: UIViewAnimationOptionCurveEaseInOut
358+ options: options
334359 animations: swapChangeBlock
335360 completion: finishedChangeBlock];
336361 } else {
0 commit comments