AlertSheetView.swift 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // AlertSheetView.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/4/17.
  6. // Copyright © 2019 南鑫林. All rights reserved.
  7. //
  8. import UIKit
  9. import FWPopupView
  10. class AlertSheetView: NSObject {
  11. /// 自定义Alert弹框样式
  12. ///
  13. /// - Parameters:
  14. /// - title: 标题
  15. /// - detailTitle: 副标题
  16. /// - confirmBlock: 完成回调
  17. /// - cancelBlock: 取消回调
  18. /// - Returns: FWAlertView
  19. class func alert(title: String = "",detailTitle:String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) {
  20. // 注意:此时“确定”按钮是不让按钮自己隐藏的
  21. let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock),
  22. FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)]
  23. // 演示:修改参数
  24. let vProperty = FWAlertViewProperty()
  25. vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275)
  26. vProperty.titleFontSize = 18.0
  27. vProperty.titleColor = UIColor.black
  28. vProperty.detailFontSize = 15.0
  29. vProperty.detailColor = k999999Color
  30. vProperty.buttonFontSize = 18.0
  31. vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
  32. vProperty.touchWildToHide = "0"
  33. // 还有很多参数可设置...
  34. let alertView = FWAlertView.alert(title: title, detail: detailTitle, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty)
  35. alertView.show()
  36. }
  37. /// 自定义Alert弹框样式
  38. ///
  39. /// - Parameters:
  40. /// - title: 标题
  41. /// - confirmBlock: 完成回调
  42. /// - cancelBlock: 取消回调
  43. /// - Returns: FWAlertView
  44. class func alert(title: String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) {
  45. // 注意:此时“确定”按钮是不让按钮自己隐藏的
  46. let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock),
  47. FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)]
  48. // 演示:修改参数
  49. let vProperty = FWAlertViewProperty()
  50. vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275)
  51. vProperty.titleFontSize = 18.0
  52. vProperty.titleColor = UIColor.black
  53. vProperty.detailFontSize = 15.0
  54. vProperty.detailColor = k999999Color
  55. vProperty.buttonFontSize = 18.0
  56. vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
  57. vProperty.touchWildToHide = "0"
  58. // 还有很多参数可设置...
  59. let alertView = FWAlertView.alert(title: title, detail: nil, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty)
  60. alertView.show()
  61. }
  62. typealias SureClosure = (_ province :Province ,_ city : City ,_ area :Area) -> Void
  63. /// 自定义sheet省市区
  64. class func sheetProvinceCityAreaView(sureClosure:@escaping (Province ,City ,Area) -> Void) {
  65. let provinceCityAreaView = ProvinceCityAreaView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 340))
  66. let vProperty = FWPopupViewProperty()
  67. vProperty.popupCustomAlignment = .bottomCenter
  68. vProperty.popupAnimationType = .frame
  69. vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
  70. vProperty.touchWildToHide = "1"
  71. vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
  72. vProperty.animationDuration = 0.5
  73. provinceCityAreaView.vProperty = vProperty
  74. provinceCityAreaView.show()
  75. provinceCityAreaView.sureClosure = {
  76. (province :Province , city : City , area :Area) in
  77. provinceCityAreaView.hide(popupDidDisappearBlock: { (popupView) in
  78. sureClosure(province, city,area)
  79. })
  80. }
  81. }
  82. /// 自定义支付View
  83. class func payAlertSheetView(sureClosure:@escaping () -> Void) {
  84. let payView = CommonPayView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 300))
  85. let vProperty = FWPopupViewProperty()
  86. vProperty.popupCustomAlignment = .bottomCenter
  87. vProperty.popupAnimationType = .frame
  88. vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
  89. vProperty.touchWildToHide = "1"
  90. vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
  91. vProperty.animationDuration = 0.5
  92. payView.vProperty = vProperty
  93. payView.show()
  94. // payView.sureClosure = {
  95. // () in
  96. // payView.hide(popupDidDisappearBlock: { (popupView) in
  97. // sureClosure(province, city,area)
  98. // })
  99. // }
  100. }
  101. }