Created
July 16, 2015 22:26
-
-
Save burhanaksendir/d9731505c9f64bf0fe3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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