Latest3.0.1
Homepagehttps://github.com/choiceyou/FWPopupView
LicenseMIT
Platformsios 8.0
Authors

IOS之弹窗 — Swift4.x/OC版本(注意:OC版本目前只实现了弹窗基类)

Platform 
Language 
License

支持pod导入:

pod 'FWPopupView'
注意:如出现 [!] Unable to find a specification for 'FWPopupView' 错误,可执行 pod repo update 命令。

简单使用:(注:可下载demo具体查看,分别有OC、Swift的demo)

/// 类初始化方法
///
/// - Parameters:
///   - title: 标题
///   - detail: 描述
///   - confirmBlock: 确定按钮回调
/// - Returns: self
open class func alert(title: String,
                     detail: String,
               confirmBlock: @escaping FWPopupItemHandler) -> FWAlertView
/// 类初始化方法
///
/// - Parameters:
///   - title: 标题
///   - itemTitles: 点击项标题
///   - itemBlock: 点击回调
///   - cancenlBlock: 取消按钮回调
///   - property: FWSheetView的相关属性
/// - Returns: self
open class func sheet(title: String?,
                 itemTitles: [String],
                  itemBlock: @escaping FWPopupItemHandler,
               cancenlBlock: @escaping FWPopupVoidBlock,
                   property: FWSheetViewProperty?) -> FWSheetView

Swift:

let alertView = FWAlertView.alert(title: "标题", detail: "描述描述描述描述") { (index) in
    print("点击了确定")
}
alertView.show()
let sheetView = FWSheetView.sheet(title: "测试", 
                             itemTitles: ["Sheet0", "Sheet1", "Sheet2", "Sheet3"], 
                              itemBlock: { (index) in
    print("Sheet:点击了第(index)个按钮")
}, cancenlBlock: {
    print("点击了取消")
})
sheetView.show()

OC:

FWAlertView *alertView = [FWAlertView alertWithTitle: @"标题" 
                                              detail: @"描述描述描述描述" 
                                        confirmBlock:^(NSInteger index) {
    NSLog(@"点击了确定");
}];
[alertView show];
FWSheetView *sheetView = [FWSheetView sheetWithTitle: @"标题" 
                                          itemTitles: @[@"Sheet0", @"Sheet1", @"Sheet2", @"Sheet3"] 
                                           itemBlock:^(NSInteger index) {
    NSLog(@"Sheet:点击了第 %ld 个按钮", (long)index);
} cancenlBlock:^{
    NSLog(@"点击了取消");
}];
[sheetView show];

效果:

FWPopupView
FWPopupView

FWPopupView
FWPopupView

FWPopupView
FWPopupView

FWPopupView
FWPopupView

FWPopupView
FWPopupView

更新记录:

“`更新记录
• v2.0.4 :
1.灰色背景默认值由原来的 alpha=0.6 改为 alpha=0.5;
2.在原类初始化方法中添加输入框键盘类型参数:UIKeyboardType(鉴于方法可能跟着版本改动,所以建议封装使用);

• v2.0.5 :
1.修复弹窗隐藏时未设置原window为keywindow的问题;

• v2.0.6 :
1.原FWPopupItemHandler改为FWPopupItemClickedBlock,增加反馈当前弹窗参数;
2.FWItemType加入参数canAutoHide:点击该按钮后会自动隐藏弹窗。这样子做能够适应更多的弹窗场景;

• v2.0.7 :
1.支持单独设置某个按钮的文字、背景颜色;

• v3.0.0(大版本) :
1.弹窗基类重构:设置视图展示位置+偏移量来设置弹窗真正需要展示的位置;有多重可选动画类型。
2.由于OC类不能继承Swift类,所以弹窗基类实现了两种语言。swift版本:FWPopupView;OC版本:FWPopupBaseView;
3.FWAlertView/FWSheetView/FWDateView使用基类提供动画类型;
4.新增FWMenuView,可实现类似QQ/微信首页右上角菜单;
5.其他细节修改;

• v3.0.1 :
1.FWPopupItemClickedBlock回调增加标题参数(注:由于不想维护多个回调,这边没有考虑兼容旧版回调,所以建议封装使用);
2.修复FWSheetView未设置标题时有多余间距的问题;



## 结尾语:

- 使用过程中发现bug请issues或(QQ群:670698309);
- 有新的需求欢迎提出;

Latest podspec

{
    "name": "FWPopupView",
    "version": "3.0.1",
    "summary": "u81eau5b9au4e49u5f39u7a97",
    "description": "u81eau5b9au4e49u5f39u7a97uff0cAlertu3001Sheetu3001Customu7c7bu578b",
    "homepage": "https://github.com/choiceyou/FWPopupView",
    "license": "MIT",
    "authors": {
        "xfg": "[email protected]"
    },
    "swift_version": "4.0",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/choiceyou/FWPopupView.git",
        "tag": "3.0.1"
    },
    "source_files": "FWPopupView/FWPopupView/FWPopupView/*.swift",
    "exclude_files": "Classes/Exclude"
}

Pin It on Pinterest

Share This