Skip to content

Kofktu/KUIPopupController

Repository files navigation

KUIPopupController

Swift CocoaPods Carthage compatible

  • Simple Popup ContentView in iOS

alt tag

Requirements

  • iOS 8.0+
  • Swift 4.0
  • Swift 3.0 (0.0.1)

Installation

CocoaPods

KUIPopupController is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!
pod "KUIPopupController"

Usage

KUIPopupContentViewProtocol

public protocol KUIPopupContentViewProtocol {
    var modalBackgroundColor: UIColor? { get } // default UIColor.black(alpha 0.6)
    var animator: KUIPopupContentViewAnimator? { get }
}

public extension KUIPopupContentViewProtocol where Self: UIView {
    public func show(_ parentViewController: UIViewController? = nil) 
    public func dismiss(_ animated: Bool) 
}

KUIPopupContentViewAnimator

public protocol KUIPopupContentViewAnimator {
    func animate(_ parameter: KUIPopupContentViewAnimatorStateParameter, completion: @escaping (Bool) -> Void)
}

KUIPopupContentViewAnimatorStateParameter:

Property Type Description
isShow Bool if the value is true, show state
contentView UIView custom view
containerView UIView popup container view
containerViewCenterX NSLayoutConstraint container view centerX constraint
containerViewCenterY NSLayoutConstraint container view centerY constraint

At a Glance

import KUIPopupController

class ContentView: UIView, KUIPopupContentViewProtocol {
    var animator: KUIPopupContentViewAnimator?
}

...

func showContentView {
  let view = ContentView()
  view.animator = KUIPopupContentViewAnimator
  view.show()
}

Authors

Taeun Kim (kofktu), kofktu@gmail.com

License

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