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

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)            
        }

你可能感兴趣的:(swift3.0 中点击按钮在按钮下方弹出视图(带尖角))