A syntactic sugar library of UIViewControllerTransitioningDelegate

README of Chinese

HCCPopup

About

A syntactic sugar library of UIViewControllerTransitioningDelegate.

Related documents from Apple: Creating Custom Presentations

Screenshot

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Release notes

1.0.0

  • Predefined alignments: topLeft, topRight, bottomLeft, bottomRight, center
  • Custom alignment: custom
  • Predefined animations: horizontal, vertical, center, reversed
  • Custom animation: support custom CGAffineTransform

Documentation

Requirements

iOS 9.0+

swift 5+

Installation

HCCPopup is a Private Pod for now. To install it, simply add the following line to your Podfile:

pod 'HCCPopup' , :git => 'https://github.com/hccxc/ios-popup.git'

Usage

Popup.Alignment

The .custom(x:y:) case in a rectangle with height h and width w describes the origin point (x * w/2 + w/2, y * h/2 + h/2) in the coordinate system of the rectangle.

Popup

// Hold your `Popup`
let popup = Popup()
popup.configuration = .init(isDismissible: isDismissible, alignment: alignment, scaleX: scaleX, scaleY: scaleY, animation: animation)
// For `presentedViewController`
// Set `Popup` as `transitioningDelegate` of `presentedViewController`
// Set `modalPresentationStyle` to `.custom`
presented.transitioningDelegate = popup
presented.modalPresentationStyle = .custom
someViewController.present(presented, animated: true)

UIViewController extension

let viewController = UIViewController()
let config = Popup.Configuration(isDismissible: isDismissible, alignment: alignment, scaleX: scaleX, scaleY: scaleY, animation: animation)
// `pup` is a readonly `Popup` instance
viewController.pup(config).present(vcToPresent, animated: true)

License

HCCPopup is available under the Apache 2.0 license. See the LICENSE file for more info.

GitHub

View Github