.. | ||
zhPopupController/Classes | ||
LICENSE | ||
README.md |
Popup your custom view is easy, support custom mask style, transition effects and gesture to drag.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- Requires iOS 8.0 or later
- Requires Automatic Reference Counting (ARC)
Installation
zhPopupController is available through CocoaPods. To install it, simply add the following line to your Podfile:
platform :ios, '8.0'
use_frameworks!
target 'You Project' do
pod 'zhPopupController', '~> 1.0'
end
Preview
Usage
- Direct use of zh_popupController popup your custom view.
[self.popupController showInView:self.view.window completion:NULL];
- Customize.
_popupController = [[zhPopupController alloc] initWithView:customView size:alert.bounds.size];
_popupController.presentationStyle = zhPopupSlideStyleTransform;
_popupController.presentationTransformScale = 1.25;
_popupController.dismissonTransformScale = 0.85;
// ...
[_popupController showInView:self.view.window completion:NULL];
- Support dismiss automatically.
/// The view will disappear after `dismissAfterDelay` seconds,default is 0 will not disappear
@property (nonatomic, assign) NSTimeInterval dismissAfterDelay;
-
Update
Observe to keyboard changes will change contentView layout
New
keyboardOffsetSpacing
properties. You can through it adjust the spacing relative to the keyboard when the keyboard appears. default is 0, The pan gesture will be invalid when the keyboard appears.If you want to make the animation consistent:
You need to call the method "becomeFirstResponder()" in "willPresentBlock", don't call it before that.
You need to call the method "resignFirstResponder()" in "willDismissBlock".
/// default is NO. if YES, Will adjust view position when keyboard changes @property (nonatomic, assign) BOOL keyboardChangeFollowed; /// default is NO. if the view becomes first responder,you need set YES to keep the animation consistent @property (nonatomic, assign) BOOL becomeFirstResponded;
_popupController.becomeFirstResponded = YES; _popupController.keyboardChangeFollowed = YES; _popupController.willPresentBlock = ^(zhPopupController * _Nonnull popupController) { [textField becomeFirstResponder]; }; _popupController.willDismissBlock = ^(zhPopupController * _Nonnull popupController) { [textField resignFirstResponder]; }; //... [_popupController show];
-
Update
-
Support present/dismiss slide style
-
When system is larger than iOS 8 will use of UIVisualEffectView to do mask blur effect.
-
- Update (November 20, 2017 v1.0.2)
-
New method
- (void)fadeDismiss
for fade out of your content view. -
In 1.0.2
zhPopupSlideStyleShrinkInOut
will be deprecated, You should usezhPopupSlideStyleShrinkInOut1
orzhPopupSlideStyleShrinkInOut2
-
Author
snail-z, haozhang0770@163.com
License
zhPopupController is available under the MIT license. See the LICENSE file for more info.