Skip to content

Instantly share code, notes, and snippets.

@burhanaksendir
Created July 16, 2015 22:26
Show Gist options
  • Save burhanaksendir/d9731505c9f64bf0fe3e to your computer and use it in GitHub Desktop.
Save burhanaksendir/d9731505c9f64bf0fe3e to your computer and use it in GitHub Desktop.
import UIKit
class demoViewController: UIViewController, UIPopoverPresentationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func button(sender: AnyObject) {
let popover = UIViewController()
popover.view.backgroundColor = UIColor.purpleColor()
popover.modalPresentationStyle = .Popover
popover.preferredContentSize = CGSizeMake(0, 0)
UIView.animateWithDuration(1.0, animations: { () -> Void in
popover.preferredContentSize = CGSizeMake(UIScreen.mainScreen().bounds.width, 100)
})
let popoverPresentationController = popover.popoverPresentationController
popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Up
popoverPresentationController?.delegate = self
popoverPresentationController?.sourceView = sender as! UIView
popoverPresentationController?.sourceRect = sender.bounds
self.presentViewController(popover, animated: true, completion: nil)
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment