60

GitHub - choiceyou/FWPopupView: 弹窗控件:支持AlertView、Sheet、自定义视图的Popu...

 5 years ago
source link: https://github.com/choiceyou/FWPopupView
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

IOS之弹窗 -- Swift4.x/OC版本(只实现了部分功能,建议两个库同时使用)

Platform  Language  License

注意:由于OC类不能继承Swift类,所以弹窗基类分别使用了OC和Swift来实现,同时OC和Swift版本分别实现了几个不同的弹窗效果。两个库可以同时存在一个项目中。

温馨提示:

鉴于方法或者属性可能跟着版本改动,因此强烈建议使用该库时封装一层后再使用!!!

支持pod导入:

use_frameworks!
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];

效果:

更新记录:

• v2.0.4 :

  • 支持图形加载完成后用户添加代理事件灰色背景默认值由原来的 alpha=0.6 改为 alpha=0.5;
  • 在原类初始化方法中添加输入框键盘类型参数:UIKeyboardType(鉴于方法可能跟着版本改动,所以建议封装使用);

• v2.0.5 :

  • 修复弹窗隐藏时未设置原window为keywindow的问题;

• v2.0.6 :

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

• v2.0.7 :

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

• v3.0.0(大版本) :

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

• v3.0.1 :

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

• v3.0.2 :

  • 增加:保证前一次弹窗销毁的处理机制;
  • FWDateView开放UIDatePicker,外部可以针对不同需求进行修改;

• v3.0.3 :

  • 修复xib加载View方式时,继承弹窗基类FWPopupView崩溃问题;
  • FWSheetView适配iPhoneX(在安全区域显示);

• v3.0.5 :

  • 为防止点击某个弹窗按钮后需要继续弹出另外一个弹窗后出错问题,改为弹窗消失后执行回调;
  • 添加支持弹簧动画效果;

• v3.0.6 :

  • 添加弹窗状态:FWPopupState;
  • 根据状态对应的进行回调,这样子可以根据实际使用来回调;

• v3.0.7 :

  • FWMenuView新增支持修改背景色等相关属性;

• v3.0.8 :

  • FWAlertView带输入框输入支持密码安全类型;

• v3.0.9 :

  • FWSheetView支持修改“取消”按钮的名称;

• v3.1.1 :

  • 添加控件:FWCustomSheetView,该控件实现了单选效果;

结尾语:

  • 使用过程中发现bug请issues或加入FW问题反馈群:670698309(此群只接受FW相关组件问题);
  • 有新的需求欢迎提出;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK