FWPopupView

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
    }()
    

效果:


FWPopupView_第1张图片
IMG_0218.PNG
FWPopupView_第2张图片
IMG_0219.PNG

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
    }()
FWPopupView_第3张图片
IMG_0714.PNG
FWPopupView_第4张图片
IMG_0715.PNG
FWPopupView_第5张图片
IMG_0716.PNG
FWPopupView_第6张图片
IMG_0717.PNG
自定义内部视图
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
    }()
    
FWPopupView_第7张图片
IMG_0718.PNG

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
    }()
FWPopupView_第8张图片
IMG_0720.PNG

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()
FWPopupView_第9张图片
IMG_0721.PNG

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
    }()
FWPopupView_第10张图片
IMG_0216.PNG
FWPopupView_第11张图片
IMG_0217.PNG

github地址自行百度

你可能感兴趣的:(FWPopupView)