lixiang1994 / LEEAlert

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

关于Actionsheet使用过程的一些问题 #142

Closed szmichaelyb closed 2 years ago

szmichaelyb commented 3 years ago

关于Actionsheet使用过程的一些问题

  1. 对每个item设置LeeItemInsets发现不生效;
  2. 设置LeeHeaderInsets,发现只会对UILabe生效,对添加到header里面的Action不生效。

对于第2点的设计还基本可以理解和接受,但是第1点,为啥要这么设计呢,是基于什么考虑呢?

lixiang1994 commented 3 years ago

LeeItemInsets是对它前一个item进行的设置, 这里有个调用顺序问题, 要注意一下

szmichaelyb commented 3 years ago

我设置的代码如下,这个顺序没问题吧:

[LEEAlert actionsheet].config
    .LeeAddTitle(^(UILabel * label) {
        label.text = title;
        label.textColor = ybColorFromHexRGB(0x999999);
        label.font = appData_.normFont(15);
        label.backgroundColor = ybRandomColor();
    })
    .LeeItemInsets(UIEdgeInsetsMake(10, 10, 10, 10)) // 对sheet中的UILabel有效果(说错了)
    .LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeDefault;
        action.attributedTitle = chText;
        action.height = itemH;
        action.borderWidth = 1;
        action.borderColor = ybColorFromHexRGB(0xEEEEEE);
        action.clickBlock = ^{
            if (block) block(chTelHL);
        };
        action.backgroundColor = ybRandomColor();
    })
    .LeeItemInsets(UIEdgeInsetsMake(10, 10, 10, 10)) // 对sheet中的acton没有效果(上一个)
    .LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeDefault;
        action.attributedTitle = hkText;
        action.height = itemH;
        action.borderWidth = 1;
        action.borderColor = ybColorFromHexRGB(0xEEEEEE);
        action.clickBlock = ^{
            if (block) block(hkTelHL);
        };
        action.backgroundColor = ybRandomColor();
        action.cornerRadius = 10;
    })
    .LeeItemInsets(UIEdgeInsetsMake(5, 15, 5, 15)) // 对sheet中的acton没有效果(上一个)
    .LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeCancel;
        action.font = font;
        action.title = @"取消";
        action.titleColor = bgColorHL;
        action.height = itemH;
        action.borderWidth = 1;
        action.borderColor = ybColorFromHexRGB(0xEEEEEE);
        action.cornerRadius = 5;
    })
    .LeeItemInsets(UIEdgeInsetsZero)
    .LeeMaxWidth(appData_.screenW)

但是确实 LeeItemInsets的设置并不生效。

lixiang1994 commented 3 years ago
.LeeItemInsets(UIEdgeInsetsZero) // 你似乎覆盖了

我在Demo上试了一下 没发现问题

szmichaelyb commented 3 years ago

不存在覆盖吧?

这个不是针对每一个 item 设置 Insets么? 最后一项是针对 cancle 的设置的把~

那前面项目分别的设置的 iteminstes 为什么不会有效果吗?

lixiang1994 commented 3 years ago

你看名字 LeeItemInsets, 针对Item的边距设置, 而不是 LeeActionInsets

lixiang1994 commented 3 years ago

我的README里面有写这个概念, 所有内容元素分为 Item和Action两种类型.

szmichaelyb commented 3 years ago

哦哦,对,是我弄混了, 仔细看demo里面有个评分alert的action间距设置,确实有区别,不一样。

要使用:

action.insets = .....

不好意思啊~

那么针对于 自定义视图,这样使用正确吗:

config.LeeItemInsets(insets);
szmichaelyb commented 3 years ago

还是有问题:

取消action设置 insets发现没有效果~

.LeeAddAction(^(LEEAction *action) {
        action.type = LEEActionTypeCancel;
        action.font = font;
        action.title = @"取消";
        action.titleColor = bgColorHL;
        action.height = itemH;
        action.borderWidth = 1;
        action.borderColor = ybColorFromHexRGB(0xeeeeee);
        action.cornerRadius = 5;
        action.backgroundColor = ybRandomColor();
        action.insets = UIEdgeInsetsMake(10, 10, 10, 10); // 没有效果
})

ActionSheet 取消按钮

lixiang1994 commented 3 years ago

ActionSheet的取消Action类型是个特殊的, 他只有一个 并且独立在外