/SemiModal

类似淘宝添加购物车的模态视图动画

Primary LanguageObjective-CMIT LicenseMIT

SemiModal

Build Platform Language License

该项目已废弃不再维护,请移步 iOS-Modal

使用者只需关心UIViewController+XPSemiModal.h提供的使用方法以及XPSemiModalConfiguration.h所提供的定制功能即可,无需关心其他文件。如果对该功能实现有兴趣,你可自行查阅其他文件源代码。

类似淘宝添加购物车的模态视图动画

参考了KNSemiModalViewController的代码,但由于KNSemiModalViewController毕竟年代久远,当时还是用的addChildViewController的方式去实现的,所以现在采用iOS7提供的转场动画API以及iOS8推出的UIPresentationController来实现该功能。

提供Swift版本的实现,请查看swift分支。

环境要求

  • iOS8.0+

用法

  • SemiModal文件夹拖入你的项目并导入#import "UIViewController+XPSemiModal.h"即可

  • 示例代码

  1. 弹出控制器
UIViewController *contentViewController = [[UIViewController alloc] init];
contentViewController.view.backgroundColor = [UIColor lightGrayColor];
XPSemiModalConfiguration *config = [XPSemiModalConfiguration defaultConfiguration];
[self presentSemiModalViewController:contentViewController contentHeight:300.0 configuration:config completion:nil];
  1. 弹出自定义视图
UIView *contentView = [[UIView alloc] init];
contentView.backgroundColor = [UIColor purpleColor];
XPSemiModalConfiguration *config = [XPSemiModalConfiguration defaultConfiguration];
[self presentSemiModalView:contentView contentHeight:300.0 configuration:config completion:^{
	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
	});
}];

演示

GIF

1.png

2.png

致谢

参考了KNSemiModalViewController的代码,感谢他们对开源社区做出的贡献。

协议

SemiModal被许可在 MIT 协议下使用。查阅LICENSE文件来获得更多信息。