Latest 0.0.4
Homepage https://github.com/Kofktu/KUIPopOver
License MIT
Platforms ios 8.0, requires ARC
Authors

Swift
CocoaPods
Carthage compatible

  • Easy to use PopOver in iOS (iPhone, iPad)

alt tag

Requirements

  • iOS 8.0+
  • Swift 3.0

Example

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

Installation

CocoaPods

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

pod 'KUIPopOver'

Carthage

For iOS 8+ projects with Carthage

github "Kofktu/KUIPopOver"

Usage

Before

let popOverViewController = DefaultPopOverViewController()
popOverViewController.preferredContentSize = CGSize(width: 200.0, height: 300.0)
popOverViewController.popoverPresentationController?.sourceView = sender

let customView = CustomPopOverView(frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 200.0, height: 300.0)))
popOverViewController.view.addSubview(customView)
popOverViewController.popoverPresentationController?.sourceRect = sender.bounds
present(popOverViewController, animated: true, completion: nil)

KUIPopOverUsable

public protocol KUIPopOverUsable {
    var contentSize: CGSize { get }
    var contentView: UIView { get }
    var arrowDirection: UIPopoverArrowDirection { get }
}

for UIView

public func showPopover(sourceView: UIView, sourceRect: CGRect)
public func showPopover(barButtonItem: UIBarButtonItem)
public func dismissPopover(animated: Bool)

for UIViewController

public func showPopover(sourceView: UIView, sourceRect: CGRect)
public func showPopover(withNavigationController sourceView: UIView, sourceRect: CGRect)
public func showPopover(barButtonItem: UIBarButtonItem)
public func showPopover(withNavigationController barButtonItem: UIBarButtonItem)
public func dismissPopover(animated: Bool)

At a Glance

for UIView

class CustomView: UIView, KUIPopOverUsable {
    // The default size is the size of the view, and you can override it if you want to customize it.
    var contentSize: CGSize {
        return Size
    }
}

let view = CustomView()
view.showPopover(barButtonItem: sender)
view.dismissPopover(animated: true)

for UIViewController

class CustomViewController: UIViewController, KUIPopOverUsable {
    var contentSize: CGSize {
        // PopOver preferredContentSize
    }
}

let customViewController = CustomViewController()

// from senderView
customViewController.showPopover(sourceView: sender, sourceRect: sender.bounds)

// from barButtonItem
customViewController.showPopover(barButtonItem: sender)

// with NavigationController
customViewController.showPopover(withNavigationController: sender, sourceRect: sender.bounds)

customViewController.dismissPopover(animated: true)

Authors

Taeun Kim (kofktu), [email protected]

License

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

Latest podspec

{
    "name": "KUIPopOver",
    "version": "0.0.4",
    "summary": "Easy to use PopOver in iOS",
    "description": "Easy to use PopOver in iOS (iPhone, iPad)",
    "homepage": "https://github.com/Kofktu/KUIPopOver",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kofktu": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Kofktu/KUIPopOver.git",
        "tag": "0.0.4"
    },
    "source_files": "KUIPopOver/Classes/**/*.{swift}",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This