swift3.0 中点击按钮在按钮下方弹出视图(带尖角)

2018-10-16  本文已影响0人  verge_l

1.当前的UIViewController需要实现 UIPopoverPresentationControllerDelegate

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
     return .none
 }

2.弹出视图

  if let pop = storyboard?.instantiateViewController(withIdentifier: "show_popover"),let btn = sender as? UIButton {
            pop.modalPresentationStyle = .popover
            pop.popoverPresentationController?.delegate = self
            pop.popoverPresentationController?.sourceView = btn
            pop.popoverPresentationController?.sourceRect = btn.bounds
            pop.preferredContentSize = CGSize(width: 200, height: 100)
            pop.popoverPresentationController?.permittedArrowDirections = .up
            present(pop, animated: true, completion: nil)            
        }
上一篇下一篇

猜你喜欢

热点阅读