preface

With the increase of APP business, a variety of bullet boxes also increase, all kinds of details need to be customized differently. Finally precipitate the JXPopupView library, can deal with multiple types of needs, lightweight and flexible, no longer for the box worry.

Recently read an article ali Cloud this group of madmen, deeply felt, a lot of awesome things are forced out, rather than a genius by his own efforts to create. Just as the article said, with the rapid growth of Taobao business, if the cloud service is not upgraded, the business will stagnate due to the technical bottleneck, which may also lead to the failure of Taobao.

For us average developers, it’s impossible to write code that meets every requirement right away (with experience, you can write code that scales well). What we’re trying to do is keep thinking and refining the code as the business changes and precipitates a framework that will stand the test.

A little chicken soup, let’s look at the details of JXPopupView.

Github

Download the source code and have a look! JXPopupView

features

  • Rich animation is provided by default, and the configuration can be flexibly extended as long as it is complied and implementedJXPopupViewAnimationProtocolAgreement can be;
  • Flexible use, view encapsulation, can be displayed on any view, not just UIViewController;
  • Background configuration is convenient for referenceMBProgressHUDThe processing logic of the background view can be flexibly configured.
  • Interaction details are configurable and providedisDismissible,isInteractive,isPenetrableAttribute configuration

preview

Animation effects

Animation effects GIF
Fade gradually now
The zoom
To the left
To the right
down
up
Part custom – Elastic animation
Fully custom animation

Background style

Background style GIF
Fixed color value
blur light
blur dark

Specify containerView

Specify containerView GIF
Window
UIViewController.view
CustomView

requirements

Swift 4.2 written, support iOS9 or above

The installation

CocoaPods

Add it to your Podfile

pod 'JXPopupView'
Copy the code

Then pod install (preferably pod update)

use

//- Determine the target frame of the contentViewlet contentView = Bundle.main.loadNibNamed("TestAlertView", owner: nil, options: nil)? .first as? TestAlertViewlet x: CGFloat = (containerView.bounds.size.width - 200)/2
lety: CGFloat = (containerView.bounds.size.height - 200)/2 contentView.frame = CGRect(x: x, y: y, width: 200, height: 200) / / - determine the animation effects var animator = JXPopupViewFadeInOutAnimator () / / - initialize JXPopupViewletpopupView = JXPopupView(containerView: containerView, contentView: contentView, animator: animator!) //- Configure interactive popupview. isdistransmissible =true
popupView.isInteractive = true
popupView.isPenetrable = false/ / - configuration background popupView. BackgroundView. Style = self. BackgroundStyle popupView. BackgroundView. BlurEffectStyle = Self. BackgroundEffectStyle popupView. BackgroundView. Color = self. Show popupView backgroundColor / / - popupView.display(animated:true, completion: Nil) / / - disappeared popupView / / through the extension of jx_popupView properties, obtain JXPopupView, can be held without global JXPopupView attribute contentView. Jx_popupView? .dismiss(animated:true, completion: nil)
Copy the code

Animation customization

JXPopupViewAnimationProtocolProtocol methods

/// /// -parameters: /// - contentView: custom popbox view /// - backgroundView: backgroundView /// - containerView: // - Returns: void func setup(contentView: UIView, backgroundView: JXBackgroundView, containerView: /// /// -parameters: /// -contentview: custom popbox view /// -backgroundview: backgroundView /// -animated: /// - completion: void func display(contentView: UIView, backgroundView: void func display) JXBackgroundView, Animated: Bool, completion: @escaping ()->()) /// process disappearing animation /// /// - Parameters: /// - contentView: Custom popbox view /// -backgroundview: backgroundView /// -animated: whether animation is required /// - completion: callback func dismiss(contentView: UIView, backgroundView: JXBackgroundView,animated: Bool, completion: @escaping ()->())Copy the code

Custom animation suggestions

  • Existing animation fine tuning inherits the corresponding Animator, overload protocol method, fine tuning. Refer to the demo project JXPopupViewSpringDownwardAnimator class.

  • Completely custom animation Can inherit JXPopupViewBaseAnimator or create a new class, follow JXPopupViewAnimationProtocol protocol, realize the corresponding method. Refer to the demo project JXPopupViewCustomAnimator class