暂无描述

AlertController.swift 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // AlertController.swift
  3. // PaiaiUIKit
  4. //
  5. // Created by ffib on 2019/1/21.
  6. // Copyright © 2019 yb. All rights reserved.
  7. //
  8. import Foundation
  9. public class AlertController: AlertViewController {
  10. public fileprivate(set) var alertView: AlertView
  11. override public var animationView: UIView? {
  12. return alertView
  13. }
  14. public var titleLabel: UILabel? {
  15. return alertView.titleLabel
  16. }
  17. public var messageLabel: UILabel? {
  18. return alertView.messageLabel
  19. }
  20. public var cancelItem: AlertItem? {
  21. return alertView.cancelItem
  22. }
  23. public var confirmItem: AlertItem? {
  24. return alertView.confirmItem
  25. }
  26. /// title and message is only avilable in type is alert
  27. public init(title: String = "", message: String = "", contentView: UIView? = nil) {
  28. alertView = .default
  29. alertView.title = title
  30. alertView.message = message
  31. alertView.contentView = contentView
  32. super.init(style: .alert)
  33. }
  34. required public init?(coder aDecoder: NSCoder) {
  35. fatalError("init(coder:) has not been implemented")
  36. }
  37. }
  38. /// MARK: API
  39. public extension AlertController {
  40. func addAlertAction(_ action: AlertAction) {
  41. alertView.addAlertAction(action)
  42. }
  43. }