FFPopup
FFPopup is a lightweight library for presenting custom views as a popup.
Features
-
Support several popup show types
- [x] None
- [x] Fade In
- [x] Grow In
- [x] Shrink In
- [x] Slide In from top, bottom, left, right
- [x] Bounce In from top, bottom, left, right, center
- [ ] Support custom
-
Support several popup dismiss types
- [x] None
- [x] Fade Out
- [x] Grow Out
- [x] Shrink Out
- [x] Slide Out to top, bottom, left, right
- [x] Bounce Out to top, bottom, left, right, center
- [ ] Support custom
-
Layout the popup in the horizontal direction
- [x] Left
- [x] Right
- [x] Center
- [x] Left of center
- [x] Right of center
- [ ] Support custom
-
Layout the popup in the vertical direction
- [x] Top
- [x] Bottom
- [x] Center
- [x] Above center
- [x] Below center
- [ ] Support custom
-
Controlled whether to allow interaction with the underlying view
- [x] Allow interaction with underlying view
- [x] Don't allow interaction with underlying view
- [x] Don't allow interaction with underlying view, dim background
- [ ] Don't allow interaction with underlying view, blur background
- [ ] Support custom
-
Others
- [ ] Complete Documentation
Requirements
- iOS 8.0+ / macOS 10.13.6+
- Xcode 10.1 (10B61) +
Example
To run the Example
project, clone the Repo, and start Example
in Xcode.
Installation
There are three ways to use FFPopup
in your project:
- Installation with
CocoaPods
- Installation with
Carthage
Manually
install
CocoaPods
CocoaPods is a dependency manager, which automates and simplifies the process of using 3rd-party libraries like FFPopup
in your projects. First, add the following line to your Podfile:
If you want to use the latest features of FFPopup
use normal external source dependencies.
This pulls from the master branch directly.
Second, install FFPopup
into your project:
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
To integrate FFPopup
into your Xcode project using Carthage, specify it in your Cartfile
:
Run the following command to build the framework:
Drag the built FFPopup.framework
binaries from Carthage/Build/iOS
into your application’s Xcode project.
On your application targets’ Build Phases
settings tab, click the + icon
and choose New Run Script Phase
. Create a Run Script
in which you specify your shell (ex: /bin/sh
), add the following contents to the script area below the shell:
Add the following paths to the frameworks you want to use under Input Files
.
$(SRCROOT)/Carthage/Build/iOS/FFPopup.framework
For an in depth guide, read on from Adding frameworks to an application
Manually
Alternatively you can directly add the FFPopup.h
and FFPopup.m
source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop
FFPopup.h
andFFPopup.m
onto your project (use the"Product Navigator view"
). Make sure to selectCopy items
when asked if you extracted the code archive outside of your project. - Include
FFPopup
wherever you need it with#import "FFPopup.h"
.
Swift
Even though FFPopup
is written in Objective-C, it can be used in Swift with no hassle. If you use CocoaPods add the following line to your Podfile:
If you added FFPopup
manually, just add a bridging header file to your project with the FFPopup
header included.
Usage
Import the library where you want to use it.
- Objective-C
- Swift
Customization
1.FFPopupShowType
Animation transition for presenting contentView. Controlled how the popup will be presented.
The default value is FFPopupShowType_BounceInFromTop
.
FFPopupShowType |
---|
FFPopupShowType_None |
FFPopupShowType_FadeIn |
FFPopupShowType_GrowIn |
FFPopupShowType_ShrinkIn |
FFPopupShowType_SlideInFromTop |
FFPopupShowType_SlideInFromBottom |
FFPopupShowType_SlideInFromLeft |
FFPopupShowType_SlideInFromRight |
FFPopupShowType_BounceIn |
FFPopupShowType_BounceInFromTop |
FFPopupShowType_BounceInFromBottom |
FFPopupShowType_BounceInFromLeft |
FFPopupShowType_BounceInFromRight |
2.FFPopupDismissType
Animation transition for dismissing contentView. Controlled how the popup will be dismissed.
The default value is FFPopupDismissType_BounceOutToBottom
.
FFPopupDismissType |
---|
FFPopupDismissType_None |
FFPopupDismissType_FadeOut |
FFPopupDismissType_GrowOut |
FFPopupDismissType_ShrinkOut |
FFPopupDismissType_SlideOutToTop |
FFPopupDismissType_SlideOutToBottom |
FFPopupDismissType_SlideOutToLeft |
FFPopupDismissType_SlideOutToRight |
FFPopupDismissType_BounceOut |
FFPopupDismissType_BounceOutToTop |
FFPopupDismissType_BounceOutToBottom |
FFPopupDismissType_BounceOutToLeft |
FFPopupDismissType_BounceOutToRight |
3.FFPopupMaskType
Mask prevents background touches from passing to underlying views. Controlled whether to allow interaction with the underlying view.
The default value is FFPopupMaskType_Dimmed
.
FFPopupMaskType |
---|
FFPopupMaskType_None |
FFPopupMaskType_Clear |
FFPopupMaskType_Dimmed |
4.Other Properties
Property Name | Description | Default Value |
---|---|---|
dimmedMaskAlpha | Overrides alpha value for dimmed mask. | 0.5 |
showInDuration | Overrides animation duration for show in. | 0.15 |
dismissOutDuration | Overrides animation duration for dismiss out. | 0.15 |
shouldDismissOnBackgroundTouch | If YES , the popup will dismiss when background is touched. |
YES |
shouldDismissOnContentTouch | If YES , the popup will dismiss when content view is touched. |
NO |
5.Blocks
6.Convenience Initializers
Create a new popup with custom values.
7.Showing the Popup
8.Dismissing the Popup
TODO List
This is the to-do list for the FFPopup
project. You can join us to become a contributor.
- [ ] Support blur option for background mask
- [ ] Support for keyboard show/hide
- [ ] Support for drag-to-dismiss