GithubHelp home page GithubHelp logo

carabina / kuipopover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kofktu/kuipopover

0.0 2.0 0.0 3.26 MB

Easy to use PopOver in iOS

License: MIT License

Swift 65.08% Ruby 32.30% Objective-C 2.62%

kuipopover's Introduction

KUIPopOver

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)

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)

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)

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
viewController.showPopover(withNavigationController: sender, sourceRect: sender.bounds)

Authors

Taeun Kim (kofktu), [email protected]

License

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

kuipopover's People

Contributors

kofktu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.