lixiang1994 / LEEAlert

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

两个action左右布局,增加上下布局 #198

Closed huluo666 closed 2 weeks ago

huluo666 commented 2 weeks ago

框架很好用,希望更新下两个LeeAddAction支持垂直布局

@interface LEEBaseConfigModel : NSObject

/** 是否强制竖排布局 */
@property (nonatomic, assign) BOOL isVerticalLayout;

/** 设置动作布局样式 -> 格式: .LeeActionLayoutStyle(YES) 表示竖排 */
@property (nonatomic, copy, readonly) LEEConfigToBool LeeActionLayoutStyle;

@end

@implementation LEEBaseConfigModel

- (LEEConfigToBool)LeeActionLayoutStyle {
    return ^(BOOL isVertical){
        self.isVerticalLayout = isVertical;
        return self;
    };
}

@end

- (CGFloat)updateActionsLayoutWithInitialPosition:(CGFloat)initialPosition MaxWidth:(CGFloat)maxWidth{
    // 当按钮数量为 2 且 isVerticalLayout == NO 时,执行左右布局
    if (self.alertActionArray.count == 2 && !self.config.isVerticalLayout) {
  }
}

使用示例 你可以在使用 LEEAlert 时通过链式配置来启用竖排布局:

[LEEAlert alert].config
.LeeTitle(@"Title")
.LeeContent(@"Content")
.LeeAddAction(^(LEEAction * _Nonnull action) {
    action.title = @"Button 1";
    action.titleColor = [UIColor redColor];
})
.LeeAddAction(^(LEEAction * _Nonnull action) {
    action.title = @"Button 2";
    action.titleColor = [UIColor redColor];
})
.LeeActionLayoutStyle(YES)  // 强制竖排
.LeeShow();
lixiang1994 commented 2 weeks ago

OK 近期会发布

lixiang1994 commented 2 weeks ago

https://github.com/lixiang1994/LEEAlert/releases/tag/1.8.0