Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. let storyboard = UIStoryboard(name: "Main", bundle: nil)
  2. let viewController = storyboard.instantiateViewController(withIdentifier: "customer_dashboard_date") as! UITableViewController
  3.  
  4. viewController.modalPresentationStyle = UIModalPresentationStyle.popover
  5. viewController.preferredContentSize = CGSize(width: 500, height: 350)
  6. let button = UIButton (frame : CGRect (x:100, y:100 ,width:100 , height:40))
  7. button.backgroundColor = UIColor.red
  8. button.setTitle("My Button", for:.normal)
  9. button.setTitleColor(UIColor.yellow, for: .normal)
  10. //viewController.view.addSubview(button)
  11. present(viewController, animated: true, completion: nil)
  12.  
  13. let popoverPresentationController = viewController.popoverPresentationController
  14. popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
  15.  
  16. popoverPresentationController?.popoverLayoutMargins = UIEdgeInsets.init(top: 0, left: 100, bottom: 0, right: 0)
  17. popoverPresentationController?.sourceView = sender
  18. popoverPresentationController?.sourceRect = CGRect(x: 70, y: 0, width: sender.frame.size.width, height: sender.frame.size.height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement