测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布时间最新版本发布时间 | 2015年6月 |
由Luke Geiger维护。
LGSemiModalNavController的目的是允许您在另一个视图控制器上动态设置视图控制器的高度。
这种自定义转换的效果是,一个视图从屏幕底部弹起并放置在适当的位置。在这个视图后面的视图会被按自定义量缩放。
有两个类协同作用来创建这种效果。LGSemiModalNavViewController和LGSemiModalTransition。LGSemiModalNavViewController订阅了UIViewControllerTransitioningDelegate。LGSemiModalTransition订阅了UIViewControllerAnimatedTransitioning。
// LGSemiModalNavViewController.m
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source {
return [self transitionPresenting:YES];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
return [self transitionPresenting:NO];
}
-(LGSemiModalTransition*)transitionPresenting:(BOOL)presenting{
LGSemiModalTransition *animator = [LGSemiModalTransition new];
animator.presenting = presenting;
animator.tapDismissEnabled = _tapDismissEnabled;
animator.animationSpeed = _animationSpeed;
animator.backgroundShadeColor = _backgroundShadeColor;
animator.scaleTransform = _scaleTransform;
animator.springDamping = _springDamping;
animator.springVelocity = _springVelocity;
animator.backgroundShadeAlpha = _backgroundShadeAlpha;
return animator;
}
//This is an example.
LGViewController *lgVC = [[LGViewController alloc]initWithFormat:LGViewControllerFormatGoBack];
//This is the nav controller
LGSemiModalNavViewController *semiModal = [[LGSemiModalNavViewController alloc]initWithRootViewController:lgVC];
//Make sure to set a height on the view controller here.
semiModal.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 400);
//Selected customization properties, see more in the header of the LGSemiModalNavViewController
semiModal.backgroundShadeColor = [UIColor blackColor];
semiModal.animationSpeed = 0.35f;
semiModal.tapDismissEnabled = YES;
semiModal.backgroundShadeAlpha = 0.4;
semiModal.scaleTransform = CGAffineTransformMakeScale(.94, .94);
[self presentViewController:semiModal animated:YES completion:nil];
要运行示例项目,首先克隆仓库,然后从示例目录运行pod install
LGSemiModalNavController通过CocoaPods提供。要安装它,只需将以下行添加到Podfile
pod "LGSemiModalNavController"
Luke Geiger,@lukejgeiger
Mathew Piccinato
LGSemiModalNavController在MIT许可证下提供。有关更多信息,请参阅LICENSE文件。