Pop-up based view(e.g. alert sheet), can be easily customized.

Related tags

Popup MMPopupView
Overview

MMPopupView

CocoaPods CocoaPods CocoaPods

中文介绍

A basic Pop-Up Kit allows you to easily create Pop-Up view. You can focus on the only view you want to show.

Besides, it comes with 2 common Pop-Up view, MMAlertView & MMSheetView. You can easily use & customize it.

demo

or you can check the demo video below(click the image).

youtube

Installation

The preferred way of installation is via CocoaPods. Just add

pod 'MMPopupView'

and run pod install. It will install the most recent version of MMPopupView.

If you would like to use the latest code of MMPopupView use:

pod 'MMPopupView', :head

Usage

//MMAlertView
NSArray *items =
@[MMItemMake(@"Done", MMItemTypeNormal, block),
  MMItemMake(@"Save", MMItemTypeHighlight, block),
  MMItemMake(@"Cancel", MMItemTypeNormal, block)];

[[[MMAlertView alloc] initWithTitle:@"AlertView"
                             detail:@"each button take one row if there are more than 2 items"
                              items:items]
 showWithBlock:completeBlock];

//MMSheetView
NSArray *items =
@[MMItemMake(@"Normal", MMItemTypeNormal, block),
  MMItemMake(@"Highlight", MMItemTypeHighlight, block),
  MMItemMake(@"Disabled", MMItemTypeDisabled, block)];

[[[MMSheetView alloc] initWithTitle:@"SheetView"
              items:items] showWithBlock:completeBlock];

MMPopupView

MMPopupView is a basic Pop-Up view designed to be subclassed. It provide 3 kind of animations(alert, sheet, drop), or you can provide your own animation by override the showAnimation and hideAnimation.

typedef NS_ENUM(NSUInteger, MMPopupType) {
    MMPopupTypeAlert,
    MMPopupTypeSheet,
    MMPopupTypeCustom,
};

@class MMPopupView;

typedef void(^MMPopupBlock)(MMPopupView *);
typedef void(^MMPopupCompletionBlock)(MMPopupView *, BOOL);

@interface MMPopupView : UIView

@property (nonatomic, assign, readonly) BOOL           visible;             // default is NO.

@property (nonatomic, strong          ) UIView         *attachedView;       // default is MMPopupWindow. You can attach MMPopupView to any UIView.

@property (nonatomic, assign          ) MMPopupType    type;                // default is MMPopupTypeAlert.
@property (nonatomic, assign          ) NSTimeInterval animationDuration;   // default is 0.3 sec.
@property (nonatomic, assign          ) BOOL           withKeyboard;        // default is NO. When YES, alert view with be shown with a center offset (only effect with MMPopupTypeAlert).

@property (nonatomic, copy            ) MMPopupCompletionBlock   showCompletionBlock; // show completion block.
@property (nonatomic, copy            ) MMPopupCompletionBlock   hideCompletionBlock; // hide completion block

@property (nonatomic, copy            ) MMPopupBlock   showAnimation;       // custom show animation block.
@property (nonatomic, copy            ) MMPopupBlock   hideAnimation;       // custom hide animation block.

/**
 *  override this method to show the keyboard if with a keyboard
 */
- (void) showKeyboard;

/**
 *  override this method to hide the keyboard if with a keyboard
 */
- (void) hideKeyboard;


/**
 *  show the popup view
 */
- (void) show;

/**
 *  show the popup view with completiom block
 *
 *  @param block show completion block
 */
- (void) showWithBlock:(MMPopupBlock)block;

/**
 *  hide the popup view
 */
- (void) hide;

/**
 *  hide the popup view with completiom block
 *
 *  @param block hide completion block
 */
- (void) hideWithBlock:(MMPopupBlock)block;

@end

/**
 *  hide all popupview with current class, eg. [MMAlertview hideAll];
 */
+ (void) hideAll;

If you want to create your own Pop-Up view,simply you only need to subclass from MMPopupView.

@interface YourCustomView : MMPopupView

@end

after you customize it, you can simply use it.

[YourCustomView show];
[YourCustomView showWithBlock:completionBlock];

[YourCustomView hide];
[YourCustomView hideWithBlock:completionBlock];

MMAlertView

MMAlertView is based on MMPopupView.

typedef void(^MMPopupInputHandler)(NSString *text);

@interface MMAlertView : MMPopupView

@property (nonatomic, assign) NSUInteger maxInputLength;    // default is 0. Means no length limit.

- (instancetype) initWithInputTitle:(NSString*)title
                             detail:(NSString*)detail
                        placeholder:(NSString*)inputPlaceholder
                            handler:(MMPopupInputHandler)inputHandler;

- (instancetype) initWithConfirmTitle:(NSString*)title
                               detail:(NSString*)detail;

- (instancetype) initWithTitle:(NSString*)title
                        detail:(NSString*)detail
                         items:(NSArray*)items;
@end

MMAlertViewConfig is the global configuration of MMAlertView, you can fully customize by adjust it.

@interface MMAlertViewConfig : NSObject

+ (MMAlertViewConfig*) globalConfig;

@property (nonatomic, assign) CGFloat width;                // Default is 275.
@property (nonatomic, assign) CGFloat buttonHeight;         // Default is 50.
@property (nonatomic, assign) CGFloat innerMargin;          // Default is 25.
@property (nonatomic, assign) CGFloat cornerRadius;         // Default is 5.

@property (nonatomic, assign) CGFloat titleFontSize;        // Default is 18.
@property (nonatomic, assign) CGFloat detailFontSize;       // Default is 14.
@property (nonatomic, assign) CGFloat buttonFontSize;       // Default is 17.

@property (nonatomic, strong) UIColor *backgroundColor;     // Default is #FFFFFF.
@property (nonatomic, strong) UIColor *titleColor;          // Default is #333333.
@property (nonatomic, strong) UIColor *detailColor;         // Default is #333333.
@property (nonatomic, strong) UIColor *splitColor;          // Default is #CCCCCC.

@property (nonatomic, strong) UIColor *itemNormalColor;     // Default is #333333. effect with MMItemTypeNormal
@property (nonatomic, strong) UIColor *itemHighlightColor;  // Default is #E76153. effect with MMItemTypeHighlight
@property (nonatomic, strong) UIColor *itemPressedColor;    // Default is #EFEDE7.

@property (nonatomic, strong) NSString *defaultTextOK;      // Default is "好".
@property (nonatomic, strong) NSString *defaultTextCancel;  // Default is "取消".
@property (nonatomic, strong) NSString *defaultTextConfirm; // Default is "确定".

@end

MMSheetView

MMSheetView is based on MMPopupView.

@interface MMSheetView : MMPopupView

- (instancetype) initWithTitle:(NSString*)title
                         items:(NSArray*)items;

@end

MMSheetViewConfig is the global configuration of MMAlertView, you can fully customize by adjust it.

@interface MMSheetViewConfig : NSObject

+ (MMSheetViewConfig*) globalConfig;

@property (nonatomic, assign) CGFloat buttonHeight;         // Default is 50.
@property (nonatomic, assign) CGFloat innerMargin;          // Default is 19.

@property (nonatomic, assign) CGFloat titleFontSize;        // Default is 14.
@property (nonatomic, assign) CGFloat buttonFontSize;       // Default is 17.

@property (nonatomic, strong) UIColor *backgroundColor;     // Default is #FFFFFF.
@property (nonatomic, strong) UIColor *titleColor;          // Default is #666666.
@property (nonatomic, strong) UIColor *splitColor;          // Default is #CCCCCC.

@property (nonatomic, strong) UIColor *itemNormalColor;     // Default is #333333. effect with MMItemTypeNormal
@property (nonatomic, strong) UIColor *itemDisableColor;    // Default is #CCCCCC. effect with MMItemTypeDisabled
@property (nonatomic, strong) UIColor *itemHighlightColor;  // Default is #E76153. effect with MMItemTypeHighlight
@property (nonatomic, strong) UIColor *itemPressedColor;    // Default is #EFEDE7.

@property (nonatomic, strong) NSString *defaultTextCancel;  // Default is "取消"

@end

Changelog

v1.7.1 Fix black screen problem when attachView is the main keyWindow. v1.7 Add blur effect.

@interface UIView (MMPopup)
@property (nonatomic, strong, readonly ) UIView            *mm_dimBackgroundBlurView;
@property (nonatomic, assign           ) BOOL              mm_dimBackgroundBlurEnabled;
@property (nonatomic, assign           ) UIBlurEffectStyle mm_dimBackgroundBlurEffectStyle;
@end

e.g.

alertView.attachedView = self.view;
alertView.attachedView.mm_dimBackgroundBlurEnabled = YES;
alertView.attachedView.mm_dimBackgroundBlurEffectStyle = UIBlurEffectStyleLight;

v1.6 Add '+ hideAll' method, improve code struct.

v1.5.3 Fixed touch problem with touchWildToHide

v1.5.2 Fixed touch problem when there are scrollviews in custom view

v1.5.1 Fixed showing problem

v1.5 Fixed rotation problem

v1.4 Adjust animation easing function. Rebuild the demo.(thx to @yoavlt)

v1.3 Bug fixed

v1.2 Now you could know whether MMPopupView is visible by using:

@property (nonatomic, assign, readonly) BOOL           visible;             // default is NO.

v1.1 Now you can attached MMPopupView to any UIView you want by using:

@property (nonatomic, strong          ) UIView         *attachedView; // default is MMPopupWindow. You can attach MMPopupView to any UIView.

v1.0 first version

Comments
  • Pod 内找不到该资源

    Pod 内找不到该资源

    使用 pod 'MMPopupView' 安装失败。 发现Pod内搜索不到该资源。

    MacPro:~$ pod search MMpopupView [!] Unable to find a pod with name matching `MMpopupView'

    Problem

    如果看到,请帮忙回复下,谢谢!😄

    opened by JimmyTM 3
  • set attachedView to keyWindow causing black screen

    set attachedView to keyWindow causing black screen

    MMAlertView *alertView = [[MMAlertView alloc] initWithTitle:kATitle detail:kATip items:items];
    alertView.attachedView = [UIApplication sharedApplication].keyWindow;
    

    alertView can show normally, but it turns black screen after click every item.

    environment: Xcode7.3

    opened by litt1e-p 2
  • MMPopupView isn't shown up

    MMPopupView isn't shown up

    Delpoyment Target: iOS 7.0 Base Target: iOS 9.0

    Version: 1.5

    [[[MMAlertView alloc] initWithConfirmTitle:@"xxxxxx" detail:nil] show];

    Never show up

    opened by bitnpc 2
  • 将AlertView添加到KeyWindow后会产生黑屏问题

    将AlertView添加到KeyWindow后会产生黑屏问题

    我将 MMAlertView 添加至 [UIApplication sharedApplication].keyWindow, 在点击 Item之后, 界面变为黑色. 我如何能够将 MMAlertView 添加至全屏幕 且 顺利执行?

    附代码:


     MMPopupItemHandler completeBlock = ^(NSInteger index){
    //***
     };
    
    NSArray *items =
      @[
     MMItemMake(@"不了,谢谢", MMItemTypeNormal, nil),
     MMItemMake(@"去注册", MMItemTypeHighlight, completeBlock)];
    
     MMAlertView *alertView = [[MMAlertView alloc] initWithTitle:@"创建新用户"
                                                                                          detail:@"该手机号未注册, 是否注册为新用户?"
                                                                                          items:items];
     alertView.attachedView = [UIApplication sharedApplication].keyWindow;
    
     [alertView show];
    
    opened by gq630960023 2
  • xib创建的崩溃信息'

    xib创建的崩溃信息'

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'hide animation must be there'

    通过xib创建一个view,xib中有个按钮,拖线后,点击按钮崩溃 //

    • (instancetype)init { self = [super init]; if (self) {

      self.type = MMPopupTypeSheet;
      
      
      self.backgroundColor = [UIColor whiteColor];
      
      [self mas_makeConstraints:^(MASConstraintMaker *make) {
          make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width);
          make.height.mas_equalTo(400);
      }];
      
      
      [self loadFormXib];
      

      } return self; }

    -(void)loadFormXib{

    UIView *xib = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
    
    
    xib.frame = self.frame;
    
    [self addSubview:xib];
    

    }

    • (IBAction)backButtonClick:(id)sender {

      [self hide]; }

    串哥给看看呗

    opened by cornerAnt 1
  • 把NSLog去掉,或者改成DEBUG模式使用

    把NSLog去掉,或者改成DEBUG模式使用

    这一行 MMPopupCategory.m

    - (void)mm_showDimBackground
    {
        ++self.mm_dimReferenceCount;
    
        NSLog(@"dim count: %@",@(self.mm_dimReferenceCount));
    
        if ( self.mm_dimReferenceCount > 1 )
        {
            return;
        }
    }
    
    opened by KelvinQQ 1
  • Made EaseIn/EaseOut animation default

    Made EaseIn/EaseOut animation default

    I made EaseIn/EaseOut anmation default. It is awesome, beautiful and natural.

    reference: https://www.google.com/design/spec/animation/authentic-motion.html

    opened by yoavlt 1
Owner
ralph li
iOS coder, baby girl's father. Looking for a remote work opportunity. :)
ralph li
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

Simform Solutions 223 Dec 2, 2022
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftEntryKit ?? Donations can be made here. Table of Contents Overview Features Example Project Example Project Installation Presets Playground Requi

Daniel Huri 6.1k Jan 6, 2023
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

逸风 77 Dec 14, 2022
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.

LNPopupController LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and

Leo Natan 2.9k Jan 2, 2023
PopupController is a controller for showing temporary popup view.

PopupController PopupController is a controller for showing temporary popup view. Demo Try PopupController on Appetize.io Installation CocoaPods pod '

daisuke sato 338 Dec 14, 2022
Subscription View Controller like the Tinder uses

SubscriptionPrompt SubscriptionPrompt is a UIViewController with a carousel at the top and a number of rows at the bottom. Written in Swift, works for

Binur Konarbai 235 Nov 17, 2022
A lightweight library for popup view

SHPopup SHPop is lightweight library used for popup view Sample One Sample Two Sample Three Features SHPopup supports a popup inside another popup wit

Shezad Ahamed 37 Oct 2, 2022
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PBPopupController PBPopupController is a framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

Patrick 58 Dec 3, 2022
JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap.

JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap. Installation Cocoapods pod 'JDSWiftHeatMap' Usage JDSwi

郭介騵 135 Dec 26, 2022
SwiftUI package to present a Bottom Sheet interactable view with the desired Detents. Also known as Half sheet.

BottomSheetSUI BottomSheetSUI is a package that gives you the ability to show a Bottom sheet intractable, where you can add your own SwiftUI view. You

Aitor Pagán 8 Nov 28, 2022
JAlert - This is "Alert View" project for UIKit + SwiftUI. you can use easily

JAlert Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation JAlert is a

Jackson 3 Feb 22, 2022
Tip-Calculation- - A program for calculate the tip. You can easily calculate it and you can split money easily

Tip-Calculation- It is a program for calculate the tip. You can easily calculate

Burak Pala 0 Jan 13, 2022
Custom-action-sheet- - Custom action sheet with swift

Custom-action-sheet- Usage let alertController: UIAlertControllerDimmed = UIAler

Girisankar G 0 Jan 19, 2022
PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item.

PTPopupWebView PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item. Requirement iOS 8.0 Inst

Takeshi Watanabe 117 Dec 3, 2022
WWFortuneWheelView - A scroll wheel that can be customized.

WWFortuneWheelView A scroll wheel that can be customized. 一個可以自訂數量的滾輪. Installation with Swift Package Manager dependencies: [ .package(url: "http

William-Weng 1 Jan 6, 2022
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

null 8 Dec 16, 2022
A highly customizable alert dialog controller that mimics Snapchat's alert dialog.

AZDialogViewController A highly customizable alert dialog controller that mimics Snapchat's alert dialog. Screenshots Installation CocoaPods: pod 'AZD

Antonio Zaitoun 771 Dec 11, 2022
BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

BPStatusBarAlert BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.

Ben.Park 131 Aug 12, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022