PopOverAlert 1.2.5

PopOverAlert 1.2.5

Takuya Ichise 维护。



PopOverAlert CocoaPods Version Platform License

PopOverAlert 是一种 PopOver 样式的弹窗视图。

当您需要在没有屏幕切换的情况下显示确认屏幕时请使用它。

图片

iPhone

示例

for Swift

import UIKit
import PopOverAlert

class SampleViewController: UIViewController, UIAdaptivePresentationControllerDelegate {

    @IBOutlet weak var baseTextView:UITextView?

    override func viewDidLoad() {
        super.viewDidLoad()

        let barButtonItem:UIBarButtonItem = UIBarButtonItem(title: "menu", style: .plain, target: self, action: #selector(SampleViewController.openAlert(sender:)))
        self.navigationItem.rightBarButtonItem = barButtonItem
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }


    @objc public func openAlert(sender:UIBarButtonItem) {

        let popOverAlertViewController = PopOverAlertViewController.instantiate()
        popOverAlertViewController.setButtonText("OK")
        popOverAlertViewController.setMessage("Do you want to send mail?")
        popOverAlertViewController.setSubMessage("When you press OK, the mail will be sent immediately.")

        popOverAlertViewController.setShowsVerticalScrollIndicator(true)
        popOverAlertViewController.setSeparatorStyle(UITableViewCellSeparatorStyle.singleLine)
        popOverAlertViewController.popoverPresentationController?.barButtonItem = sender
        popOverAlertViewController.preferredContentSize = CGSize(width: 300, height:110)
        popOverAlertViewController.presentationController?.delegate = self

        popOverAlertViewController.setMessageFont(UIFont.systemFont(ofSize: 16))
        popOverAlertViewController.setSubMessageFont(UIFont.systemFont(ofSize: 12))
        popOverAlertViewController.setButtonTextFont(UIFont.systemFont(ofSize: 14))
        popOverAlertViewController.setButtonTextColor(UIColor.black)

        popOverAlertViewController.completionHandler = { () -> Void in

        }
        present(popOverAlertViewController, animated: true, completion: nil)
    }

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

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

CocoaPods 安装

pod PopOverAlert

CocoaPods URL

许可协议

PopOverAlert 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。