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

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

作者: verge_l | 来源:发表于2018-10-16 15:36 被阅读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 中点击按钮在按钮下方弹出视图(带尖角)

          本文链接:https://www.haomeiwen.com/subject/kmpjottx.html