• Stars
    star
    139
  • Rank 255,454 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

一个轻量级的自定义视图弹出框架

JXPopupView

一个轻量级的自定义视图弹出框架,可灵活配置动画、背景风格。

特性

  • 默认提供丰富的动画效果,而且可以灵活的扩展配置,只要遵从并实现PopupViewAnimator协议即可;
  • 使用范围更广,通过view封装,可以在任何view上面展示,并不局限于UIViewController;
  • 弹框背景配置灵活,借鉴了MBProgressHUD对背景视图的处理逻辑;
  • 交互细节可配置,提供了isDismissibleisInteractiveisPenetrable属性进行配置;

预览

动画效果

动画效果 GIF
渐隐渐现 GIF
缩放 GIF
往左 GIF
往右 GIF
往下 GIF
往上 GIF
弹性动画 GIF
完全自定义动画 GIF

Layout布局方式

动画效果 GIF
Top顶部 GIF
Bottom底部 GIF
Leading前部 GIF
Trailing尾部 GIF
Center 居中(无示意图)
Frame 自定义frame(无示意图)

背景风格

背景风格 GIF
固定色值 GIF
blur light GIF
blur dark GIF

指定containerView

指定containerView GIF
Window GIF
UIViewController.view GIF
CustomView GIF

要求

iOS: 9+ XCode: 12.1+ swift: 5.0+

安装

CocoaPods

在Podfile文件里面添加

pod 'JXPopupView'

然后再pod install(最好先pod update)

使用

//- 确定contentView的布局方式
enum Layout {
    case center(Center)
    case top(Top)
    case bottom(Bottom)
    case leading(Leading)
    case trailing(Trailing)
    case frame(CGRect)
}
//如果contentView重载了intrinsicContentSize属性并返回其内容的CGSize,就无需再设置width、height值。
let layout: BaseAnimator.Layout = .center(.init(offsetY: 0, offsetX: 0, width: 200, height: 200))
//- 确定动画效果
let animator = FadeInOutAnimator(layout: layout)
//- 初始化JXPopupView
let contentView = TestAlertView()
let popupView = JXPopupView(containerView: containerView, contentView: contentView, animator: animator)
//- 配置交互
popupView.isDismissible = true
popupView.isInteractive = true
popupView.isPenetrable = false
//- 配置背景
popupView.backgroundView.style = self.backgroundStyle
popupView.backgroundView.blurEffectStyle = self.backgroundEffectStyle
popupView.backgroundView.color = self.backgroundColor
//- 展示popupView
popupView.display(animated: true, completion: nil)
//- 消失popupView
//通过extension提供的popupView方法,获取JXPopupView进行操作,可以不用全局持有JXPopupView属性
contentView.popupView()?.dismiss(animated: true, completion: nil)

动画自定义

PopupViewAnimator协议方法

    /// 初始化配置动画驱动器
    ///
    /// - Parameters:
    ///   - popupView: PopupView
    ///   - contentView: 自定义的弹框视图
    ///   - backgroundView: 背景视图
    /// - Returns: void
    func setup(popupView: PopupView, contentView: UIView, backgroundView: PopupView.BackgroundView)containerView: UIView)

    /// 处理展示动画
    ///
    /// - Parameters:
    ///   - contentView: 自定义的弹框视图
    ///   - backgroundView: 背景视图
    ///   - animated: 是否需要动画
    ///   - completion: 动画完成后的回调
    /// - Returns: void
    func display(contentView: UIView, backgroundView: JXBackgroundView, animated: Bool, completion: @escaping ()->())

    /// 处理消失动画
    ///
    /// - Parameters:
    ///   - contentView: 自定义的弹框视图
    ///   - backgroundView: 背景视图
    ///   - animated: 是否需要动画
    ///   - completion: 动画完成后的回调
    func dismiss(contentView: UIView, backgroundView: JXBackgroundView,animated: Bool, completion: @escaping ()->())

自定义动画建议

  • 完全自定义动画 可以继承BaseAnimator或者自己新建一个类,遵从PopupViewAnimator协议,实现对应方法即可。参考demo工程的BaseAnimator

证书

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

More Repositories

1

JXCategoryView

A powerful and easy to use category view (segmentedcontrol, segmentview, pagingview, pagerview, pagecontrol) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)
Objective-C
6,026
star
2

JXPagingView

类似微博主页、简书主页等效果。多页面嵌套,既可以上下滑动,也可以左右滑动切换页面。支持HeaderView悬浮、支持下拉刷新、上拉加载更多。
Objective-C
2,824
star
3

JXSegmentedView

A powerful and easy to use segmented view (segmentedcontrol, pagingview, pagerview, pagecontrol, categoryview) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)
Swift
2,596
star
4

JXPageListView

高仿闲鱼、转转、京东、中央天气预报等主流APP列表底部分页滚动视图
Objective-C
421
star
5

JXMarqueeView

A powerful and easy to use marquee view.
Swift
365
star
6

JXBottomSheetView

A useful and gesture interaction BottomSheetView!
Swift
256
star
7

JXTheme

A powerful and lightweight and customization theme/skin library for iOS 9+ in swift. 主题、换肤、暗黑模式
Swift
243
star
8

JXPatternLock

An easy-to-use, powerful, customizable pattern lock view in swift. 图形解锁/手势解锁 / 手势密码 / 图案密码 / 九宫格密码
Swift
219
star
9

JXMovableCellTableView

The custom tableView which can start moving the cell with a long press gesture.
Objective-C
188
star
10

StackUI

StackUI just like SwiftUI
Swift
117
star
11

JXScratchView

一个万能的刮刮乐控件。无论是UILabel、UIImageView,还是自定义视图,只要是UIView都可以用来刮。代码简单,功能强大,你值得拥有!
Swift
111
star
12

JXWeChatFloatView

高仿微信文章悬浮球
Swift
100
star
13

JXBottomSheetTableView

A highly packaged, easy to use custom bottom sheet UITableView.
Swift
48
star
14

JXExcel

一个轻量级的表视图
Swift
31
star
15

JXTableViewZoomHeaderImageView

一般app的个人资料页面都会有个头图,并且随着上下滚动的时候,图片有个移动和缩放的效果。
Objective-C
29
star
16

ModelAdapter

Simple JSON Object mapping and SQLite3 written in Swift
Swift
26
star
17

JXCaptain

像美国队长一样威猛的应用调试工具箱!
Swift
22
star
18

JXFileBrowserController

The debug sandbox browser for sharing.
Swift
22
star
19

JXGradientKit

常用控件背景渐变色Kit
Swift
19
star
20

JXLayerAutoLayout

优雅的实现CALayer AutoLayout
Objective-C
19
star
21

SQLiteValueExtension

SQLiteValueExtension for SQLite.swift
Swift
14
star
22

JXParallaxCell

用于滚动scrollview的时候,cell中的图片,或者其他控件,有一个视差滚动的效果
Objective-C
14
star
23

JXTransition

自定义转场动画
Objective-C
11
star
24

JXBorderCellll

一个有边框的基类cell
Objective-C
11
star
25

JXInterview

Interview for iOSer
10
star
26

XPackage

自己常用的一些工具
Objective-C
4
star
27

30DaysChallenge

There may be a miracle happen if you insist 30 days challenge!
Objective-C
3
star
28

JXExampleImages

示例图片资源
2
star
29

JXKit

JXKit for iOS
Swift
1
star
30

OnePiece

Swift
1
star
31

JXRomanticAlbum

谁说程序员不浪漫?我们可以用代码表白!Who says programmers aren't romantic? We can use the code to express love!
Swift
1
star