Giter Site home page Giter Site logo

semimodal's Introduction

SemiModal

Build Platform Language License

使用者只需关心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文件来获得更多信息。

semimodal's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.