lixiang1994 / LEEAlert

优雅的可自定义 Alert ActionSheet
MIT License
1.3k stars 204 forks source link

能动态添加actionsheet的action么? #135

Closed mrcrow closed 3 years ago

mrcrow commented 3 years ago

想动态添加actionsheet里的action,但show之后什么都没有,代码如下

 LEEBaseConfigModel *configuration = [LEEAlert actionsheet].config
 .LeeTitle(@"选择");

        for (Object *a in objects) {
            configuration.LeeAddAction(^(LEEAction * _Nonnull action) {
                action.title = a.name;
                action.type = LEEActionTypeDefault;
                action.titleColor = [ACColorCompatibility systemBlueColor];
                action.font = [UIFont systemFontOfSize:18];
                action.clickBlock = ^{

                };
            });
        }

        configuration.LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = @"取消";
            action.type = LEEActionTypeCancel;
            action.titleColor = [ACColorCompatibility systemBlueColor];
            action.font = [UIFont systemFontOfSize:18];
            action.clickBlock = ^{

            };
        })
        .LeeActionSheetCancelActionSpaceColor([ACColorCompatibility secondarySystemBackgroundColor]) // 设置取消按钮间隔的颜色
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距为0
        .LeeCornerRadii(CornerRadiiMake(0, 0, 0, 0))   // 指定整体圆角半径
        .LeeActionSheetHeaderCornerRadii(CornerRadiiZero()) // 指定头部圆角半径
        .LeeActionSheetCancelActionCornerRadii(CornerRadiiZero()) // 指定取消按钮圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type) {
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        })
        .LeeActionSheetBackgroundColor([ACColorCompatibility systemBackgroundColor]) // 通过设置背景颜色来填充底部间隙
        #ifdef __IPHONE_13_0
        .LeeUserInterfaceStyle(UIUserInterfaceStyleLight)
        #endif
        .LeeShow();
mrcrow commented 3 years ago

参考了 #74,搞定了