// // AlertSheetView.swift // RainbowPlanet // // Created by 南鑫林 on 2019/4/17. // Copyright © 2019 南鑫林. All rights reserved. // import UIKit import FWPopupView class AlertSheetView: NSObject { /// 自定义Alert弹框样式 /// /// - Parameters: /// - title: 标题 /// - detailTitle: 副标题 /// - confirmBlock: 完成回调 /// - cancelBlock: 取消回调 /// - Returns: FWAlertView class func alert(title: String = "",detailTitle:String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) { // 注意:此时“确定”按钮是不让按钮自己隐藏的 let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock), FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)] // 演示:修改参数 let vProperty = FWAlertViewProperty() vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275) vProperty.titleFontSize = 18.0 vProperty.titleColor = UIColor.black vProperty.detailFontSize = 15.0 vProperty.detailColor = k999999Color vProperty.buttonFontSize = 18.0 vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "0" // 还有很多参数可设置... let alertView = FWAlertView.alert(title: title, detail: detailTitle, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty) alertView.show() } /// 自定义Alert弹框样式 /// /// - Parameters: /// - title: 标题 /// - confirmBlock: 完成回调 /// - cancelBlock: 取消回调 /// - Returns: FWAlertView class func alert(title: String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) { // 注意:此时“确定”按钮是不让按钮自己隐藏的 let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock), FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)] // 演示:修改参数 let vProperty = FWAlertViewProperty() vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275) vProperty.titleFontSize = 18.0 vProperty.titleColor = UIColor.black vProperty.detailFontSize = 15.0 vProperty.detailColor = k999999Color vProperty.buttonFontSize = 18.0 vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "0" // 还有很多参数可设置... let alertView = FWAlertView.alert(title: title, detail: nil, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty) alertView.show() } typealias SureClosure = (_ province :Province ,_ city : City ,_ area :Area) -> Void /// 自定义sheet省市区 class func sheetProvinceCityAreaView(sureClosure:@escaping (Province ,City ,Area) -> Void) { let provinceCityAreaView = ProvinceCityAreaView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 340)) let vProperty = FWPopupViewProperty() vProperty.popupCustomAlignment = .bottomCenter vProperty.popupAnimationType = .frame vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "1" vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) vProperty.animationDuration = 0.5 provinceCityAreaView.vProperty = vProperty provinceCityAreaView.show() provinceCityAreaView.sureClosure = { (province :Province , city : City , area :Area) in provinceCityAreaView.hide(popupDidDisappearBlock: { (popupView) in sureClosure(province, city,area) }) } } /// 自定义支付View class func payAlertSheetView(sureClosure:@escaping () -> Void) { let payView = CommonPayView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 300)) let vProperty = FWPopupViewProperty() vProperty.popupCustomAlignment = .bottomCenter vProperty.popupAnimationType = .frame vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "1" vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) vProperty.animationDuration = 0.5 payView.vProperty = vProperty payView.show() // payView.sureClosure = { // () in // payView.hide(popupDidDisappearBlock: { (popupView) in // sureClosure(province, city,area) // }) // } } /// 分享 class func sheetShareView() { let view = ShareView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 250)) let vProperty = FWPopupViewProperty() vProperty.popupCustomAlignment = .bottomCenter vProperty.popupAnimationType = .frame vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "1" vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) vProperty.animationDuration = 0.2 view.vProperty = vProperty view.show() } /// 单个选择器 func sheetPickViewOneComponentsView(titles:[String],title:String,height:CGFloat,sureClosure:((_ row: Int,_ value:String) -> Void)?) { let view = PickViewOneComponentsView(titles: titles,title: title) view.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: height * kScaleWidth + kSafeTabBarHeight) let vProperty = FWPopupViewProperty() vProperty.popupCustomAlignment = .bottomCenter vProperty.popupAnimationType = .frame vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5) vProperty.touchWildToHide = "1" view.vProperty = vProperty view.sureClosure = { (row,value) in sureClosure!(row!,value!) view.hide() } view.show() } }