FWPopupView使用
主要类使用说明:
FWCustomSheetView
lazy var customSheetView: FWCustomSheetView = {
let property = FWCustomSheetViewProperty()
property.popupViewItemHeight = 40
property.selectedIndex = 1
let titles = ["EOS", "DICE", "ZKS"]
let customSheetView = FWCustomSheetView.sheet(headerTitle: "选择代币", itemTitles: titles, itemSecondaryTitles: nil, itemImages: nil, itemBlock: { (popupView, index, title) in
print("customSheet:点击了第\(index)个按钮")
}, property: property)
return customSheetView
}()
效果:
FWAlertView:传统alert内部可以自定义视图
lazy var alertImage: FWAlertView = {
let block2: FWPopupItemClickedBlock = { [weak self] (popupView, index, title) in
if index == 1 {
// 这边演示了如何手动去调用隐藏
self?.alertImage.hide()
}
}
// 注意:此时“确定”按钮是不让按钮自己隐藏的
let items = [FWPopupItem(title: "取消", itemType: .normal, isCancel: true, canAutoHide: true, itemClickedBlock: block2),
FWPopupItem(title: "确定", itemType: .normal, isCancel: false, canAutoHide: false, itemClickedBlock: block2)]
// 注意:添加自定义的视图,需要设置确定的Frame值
let customImageView = UIImageView(image: UIImage(named: "audio_bgm_4"))
let vProperty = FWAlertViewProperty()
vProperty.touchWildToHide = "1"
let alertImage = FWAlertView.alert(title: "标题", detail: "带自定义视图", inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: customImageView, items: items, vProperty: vProperty)
return alertImage
}()
自定义内部视图
lazy var alertImage: FWAlertView = {
let block2: FWPopupItemClickedBlock = { [weak self] (popupView, index, title) in
if index == 1 {
// 这边演示了如何手动去调用隐藏
self?.alertImage.hide()
}
}
// 注意:此时“确定”按钮是不让按钮自己隐藏的
let items = [FWPopupItem(title: "取消", itemType: .normal, isCancel: true, canAutoHide: true, itemClickedBlock: block2),
FWPopupItem(title: "确定", itemType: .normal, isCancel: false, canAutoHide: false, itemClickedBlock: block2)]
// 注意:添加自定义的视图,需要设置确定的Frame值
let customImageView = UIImageView(image: UIImage(named: "audio_bgm_4"))
let vProperty = FWAlertViewProperty()
vProperty.touchWildToHide = "1"
let alertImage = FWAlertView.alert(title: "标题", detail: "带自定义视图", inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: customImageView, items: items, vProperty: vProperty)
return alertImage
}()
FWSheetView:传统表格
lazy var sheetView: FWSheetView = {
let items = ["确定"]
let vProperty = FWSheetViewProperty()
vProperty.touchWildToHide = "1"
vProperty.titleColor = UIColor.lightGray
vProperty.titleFontSize = 15.0
let sheetView = FWSheetView.sheet(title: "你们知道微信中为什么经常使用这种提示,而不使用Alert加两个按钮的那种提示吗?", itemTitles: items, itemBlock: { (popupView, index, title) in
print("Sheet:点击了第\(index)个按钮")
}, cancenlBlock: {
print("点击了取消")
}, property: vProperty)
return sheetView
}()
FWDateView:日期选择
let dateView = FWDateView.date(confirmBlock: { (datePicker) in
print("当前选定时间:\(datePicker.date)")
}, cancelBlock: {
print("点击了 FWDateView 的取消")
})
dateView.datePicker.minimumDate = Date()
dateView.datePicker.locale = Locale(identifier: "zh_Hans_CN")
dateView.datePicker.datePickerMode = .dateAndTime
dateView.datePicker.calendar = Calendar.current
dateView.show()
FWMenuView:列表枚举视图,菜单视图
lazy var menuView1: FWMenuView = {
let vProperty = FWMenuViewProperty()
vProperty.popupCustomAlignment = .topCenter
vProperty.popupAnimationType = .scale
vProperty.popupArrowStyle = .round
vProperty.touchWildToHide = "1"
vProperty.topBottomMargin = 0
vProperty.maskViewColor = UIColor(white: 0, alpha: 0.3)
let menuView = FWMenuView.menu(itemTitles: titles, itemImageNames: images as? [UIImage], itemBlock: { (popupView, index, title) in
print("Menu:点击了第\(index)个按钮")
}, property: vProperty)
menuView.attachedView = self.view
return menuView
}()
github地址自行百度