All Projects → HeathWang → Hwpanmodal

HeathWang / Hwpanmodal

Licence: mit
HWPanModal presents controller from bottom and drag to dismiss, high customize. iOS13 default modalPresentationStyle. 任意形式的底部弹框动画;头条、知乎、抖音弹出评论效果;地图浮层,iOS13 present默认模态效果。

Projects that are alternatives of or similar to Hwpanmodal

react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (-15.29%)
Mutual labels:  drag-drop, popup, bottomsheet
Xam.plugin.simplebottomdrawer
Just a nice and simple BottomDrawer for your Xamarin Forms project
Stars: ✭ 92 (-87.1%)
Mutual labels:  popup, bottomsheet
Hwpopcontroller
pop up your ViewController with custom size, position and animations
Stars: ✭ 113 (-84.15%)
Mutual labels:  ios-ui, popup
Anylayer
Android稳定高效的浮层创建管理框架
Stars: ✭ 745 (+4.49%)
Mutual labels:  popup, bottomsheet
Nativepopup
Clone of Apple iOS App's feedback popup, and easily customizable.
Stars: ✭ 247 (-65.36%)
Mutual labels:  ios-ui, popup
RDPopup
A simple way to add custom Popup. Design on Nib and use as you want. Written in Objective-C.
Stars: ✭ 19 (-97.34%)
Mutual labels:  popup, ios-ui
Xpopup
🔥XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!(Powerful and Beautiful Popup for Android,can absolutely replace Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner. With built-in animators , very easy to custom popup v…
Stars: ✭ 6,106 (+756.38%)
Mutual labels:  popup, bottomsheet
Needs
🌂 An easy way to implement modern permission instructions popup.
Stars: ✭ 546 (-23.42%)
Mutual labels:  popup
Iosproject
iOS project of collected some demos for iOS App, use Objective-C
Stars: ✭ 5,357 (+651.33%)
Mutual labels:  ios-ui
Jquery Popup Overlay
jQuery plugin for responsive and accessible modal windows and tooltips
Stars: ✭ 511 (-28.33%)
Mutual labels:  popup
Motion
Reactive frontend UI components for Rails in pure Ruby
Stars: ✭ 498 (-30.15%)
Mutual labels:  presenter
Sweetalert
A beautiful replacement for JavaScript's "alert"
Stars: ✭ 21,871 (+2967.46%)
Mutual labels:  popup
Ffpopup
⛩ Presenting custom views as a popup in iOS.
Stars: ✭ 618 (-13.32%)
Mutual labels:  popup
Mkdropdownmenu
🔻 Dropdown Menu for iOS with many customizable parameters to suit any needs
Stars: ✭ 523 (-26.65%)
Mutual labels:  ios-ui
Selectabletextview
A text view that supports selection and expansion
Stars: ✭ 626 (-12.2%)
Mutual labels:  ios-ui
Search Dialog
An easy to use, yet very customizable search dialog
Stars: ✭ 503 (-29.45%)
Mutual labels:  popup
Sweet Alert
A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL
Stars: ✭ 696 (-2.38%)
Mutual labels:  popup
Blueprinter
Simple, Fast, and Declarative Serialization Library for Ruby
Stars: ✭ 623 (-12.62%)
Mutual labels:  presenter
Miblurpopup
MIBlurPopup lets you create popups with a blurred background
Stars: ✭ 598 (-16.13%)
Mutual labels:  popup
Popupview
Toasts and popups library written with SwiftUI
Stars: ✭ 581 (-18.51%)
Mutual labels:  popup

HWPanModal 👍

codebeat badge

HWPanModal is used to present controller and drag to dismiss. Similar with iOS13 default present Modal style.

Inspired by PanModal, thanks.

中文文档说明

My another project for pop controller:HWPopController

Special Thanks

Special Thanks to JetBrains! I use AppCode IDE to develop my open source project.

Snapshoot

Basic Blur background Keyboard handle App demo

Index

Features

  1. Supports any type of UIViewController to present.
  2. Support View which inherit from HWPanModalContentView to present.
  3. Seamless transition between modal and content.
  4. Support two kinds of dismissal gestureRecognizer interaction
    1. Pan gesture direction up&down
    2. Pan gesture direction right, you can swipe on screen edge to dismiss controller.
  5. Support write your own animation for presenting VC.
  6. Support config animation Duration, AnimationOptions, springDamping.
  7. Support config background alpha or blur background. Note: Dynamic change blur effect ONLY works on iOS9.0+.
  8. Show / hide corner, indicator.
  9. Auto handle UIKeyboard show/hide.
  10. Hight customize indicator view.
  11. Touch event response can pass through to presenting VC.
  12. Config presented view shadow style.

More config pls see HWPanModalPresentable.h declare.

What's different between UIViewController and HWPanModalContentView to present ?

From version 0.6.0, this framework support using HWPanModalContentView to present from bottom, that means we can add subview(inherit from HWPanModalContentView) to the target view that you want to show.

The different is HWPanModalContentView is just a view, and support some animations, unlike present ViewController, you will got ViewController life circle, and navigation stack.

HWPanModalContentView limit:

  • Currently not support screen rotation.
  • Not support edge horizontal pan to dismiss.
  • Not support customize presentingVC animation. (There is no presentingVC for view).

TODO

  • [x] Handle keyboard show&dismiss.
  • [x] High customize indicator view.
  • [x] Edge Interactive dismissal can work on full screen and configable distance to left edge.
  • [x] Touch event can response to presenting VC, working on it.
  • [x] Strip the presented view container view, make it can use directly.

Compatibility

iOS 8.0+, support Objective-C & Swift.

Installation

CocoaPods

pod 'HWPanModal', '~> 0.6.0'

How to use

How to present UIViewController from bottom

Your UIViewController need to conform HWPanModalPresentable. If you use default, nothing more will be written.

#import <HWPanModal/HWPanModal.h>
@interface HWBaseViewController () <HWPanModalPresentable>

@end

@implementation HWBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

#pragma mark - HWPanModalPresentable
- (PanModalHeight)longFormHeight {
    return PanModalHeightMake(PanModalHeightTypeMaxTopInset, 44);
}
@end

Where you need to present this Controller.

#import <HWPanModal/HWPanModal.h>
[self presentPanModal:[HWBaseViewController new]];

yeah! Easy.

Change state, scrollView contentOffset, reload layout. IMPORTANT!

When You present you Controller, you can change the UI. Refer to UIViewController+Presentation.h.

  • Change the state between short and long form. call - (void)hw_panModalTransitionTo:(PresentationState)state;
  • Change ScrollView ContentOffset. call - (void)hw_panModalSetContentOffset:(CGPoint)offset;
  • Reload layout. call - (void)hw_panModalSetNeedsLayoutUpdate;
    • Note: When your scrollable changed it's contentSize, you MUST reload the layout.

Custom Presenting VC Animation

Some guys want to animate Presenting VC when present/dismiss.

  1. Create object conforms HWPresentingViewControllerAnimatedTransitioning .

    
    @interface HWMyCustomAnimation : NSObject <HWPresentingViewControllerAnimatedTransitioning>
    
    @end
    
    @implementation HWMyCustomAnimation
    
    
    - (void)presentAnimateTransition:(id<HWPresentingViewControllerContextTransitioning>)transitionContext {
        NSTimeInterval duration = [transitionContext transitionDuration];
        UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
        // replace it.
        [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            fromVC.view.transform = CGAffineTransformMakeScale(0.95, 0.95);
        } completion:^(BOOL finished) {
            
        }];
    }
    
    - (void)dismissAnimateTransition:(id<HWPresentingViewControllerContextTransitioning>)transitionContext {
        // no need for using animating block.
        UIViewController *toVC = [context viewControllerForKey:UITransitionContextToViewControllerKey];
        toVC.view.transform = CGAffineTransformIdentity;
    }
    
    @end
    
  2. Overwrite below two method.

    
    - (PresentingViewControllerAnimationStyle)presentingVCAnimationStyle {
        return PresentingViewControllerAnimationStyleCustom;
    }
    
    - (id<HWPresentingViewControllerAnimatedTransitioning>)customPresentingVCAnimation {
        return self.customAnimation;
    }
    
    - (HWMyCustomAnimation *)customAnimation {
        if (!_customAnimation) {
            _customAnimation = [HWMyCustomAnimation new];
        }
        return _customAnimation;
    }
    

Custom your own indicator view

You just need to create your own UIView, then adopt HWPanModalIndicatorProtocol.

In your presented controller, return it:

- (nullable UIView <HWPanModalIndicatorProtocol> *)customIndicatorView {
    HWTextIndicatorView *textIndicatorView = [HWTextIndicatorView new];
    return textIndicatorView;
}

Here is HWTextIndicatorView code:

@interface HWTextIndicatorView : UIView <HWPanModalIndicatorProtocol>

@end

@interface HWTextIndicatorView ()
@property (nonatomic, strong) UILabel *stateLabel;
@end

@implementation HWTextIndicatorView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // init the _stateLabel
        [self addSubview:_stateLabel];
    }
    return self;
}


- (void)didChangeToState:(HWIndicatorState)state {
    switch (state) {
        case HWIndicatorStateNormal: {
            self.stateLabel.text = @"Please pull down to dismiss";
            self.stateLabel.textColor = [UIColor whiteColor];
        }
            break;
        case HWIndicatorStatePullDown: {
            self.stateLabel.text = @"Keep pull down to dismiss";
            self.stateLabel.textColor = [UIColor colorWithRed:1.000 green:0.200 blue:0.000 alpha:1.00];
        }
            break;
    }
}

- (CGSize)indicatorSize {
    return CGSizeMake(200, 18);
}

- (void)setupSubviews {
    self.stateLabel.frame = self.bounds;
}

@end

How to use HWPanModalContentView

You should always inherit from HWPanModalContentView. HWPanModalContentView conforms HWPanModalPresentable like the way using UIViewController.

@interface HWSimplePanModalView : HWPanModalContentView

@end

@implementation HWSimplePanModalView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // add view and layout.
    }
    
    return self;
}

// present it.
HWSimplePanModalView *simplePanModalView = [HWSimplePanModalView new];
[simplePanModalView presentInView:nil];

Example

  1. Clone this git.
  2. open the terminal, run pod install
  3. Double click HWPanModal.xcworkspace, and select a target to run.
I have wrote both pure Objective-C & SwiftExamples , for most of the framework functions.

Contact Me

Heath Wang [email protected]

WeChat

Change Log

Click Me

License

HWPanModal is released under a MIT License. See LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].