iOS 模态弹框工具类

1,367 阅读1分钟
原文链接: github.com

Version Platform License

SRMModalViewController support a easy way to display a view with modal style.

Installation

SRMModalViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SRMModalViewController"

Usage

UIViewController *viewController = [UIViewController new];
viewController.view.frame = CGRectMake(0, 0, 200, 200);
viewController.view.backgroundColor = [UIColor whiteColor];
[[SRMModalViewController sharedInstance] showViewWithController:viewController];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
view.backgroundColor = [UIColor whiteColor];
[[SRMModalViewController sharedInstance] showView:view];

Custom color and opacity of background mask.

[SRMModalViewController sharedInstance].backgroundColor = [UIColor blackColor];

[SRMModalViewController sharedInstance].backgroundOpacity = 0.5;

Show another one in a modal view diplayed already.

// Hide first one
[[SRMModalViewController sharedInstance] showView:self.contentView];
// Do not hide first one
SRMModalViewController *modalViewController = [SRMModalViewController new];
[modalViewController showView:self.contentView];

You can download example project to get more info.

Author

S.R, firecrackerinlane2@gmail.com

License

SRMModalViewController is available under the MIT license. See the LICENSE file for more info.