dboydor / PopoverResize

A resizable NSPopover implementation written in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PopoverResize adds the ability to resize a NSPopover. It shows resize icons when you hover over the edges of the popover window, indicating to the user they can resize.

This is how it looks within my app, Library Express:

Watch the video

How to use PopoverResize

1. Import the framework:

@import PopoverResize

2. Create the PopoverResize instance, giving it a minimum and maximum size. The CGFloat(0) indicates to use the current screen's height.

let min = NSSize(width: CGFloat(150), height: CGFloat(50))
let max = NSSize(width: CGFloat(800), height: CGFloat(0))
popover = PopoverResize(min: min, max: max)

3. Set the content view controller for the popup.

popover.setContentViewController(ViewController.create())

4. Set a callback for the resized event

popover.resized {(size: NSSize) in
    print("Popover resized: \(size)")
}

See the PopoverResizeSample app for a complete example.

Installation

PopoverResize can be installed with CocoaPods.

CocoaPods

Add this to your Podspec:

pod 'PopoverResize', :git => 'https://github.com/dboydor/PopoverResize'

Then run pod install.

License

The MIT License (MIT)

Copyright (c) 2018 David Boyd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A resizable NSPopover implementation written in Swift

License:BSD 2-Clause "Simplified" License


Languages

Language:Swift 90.6%Language:Ruby 5.6%Language:Objective-C 3.7%