Skip to content

Commit

Permalink
增加windowLevel设置 调整action的borderwidth最小宽度
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang1994 committed Jun 22, 2017
1 parent eba7f8a commit 6c88c9c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LEEAlert/LEEAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
/** 设置 是否加入到队列 -> 格式: .LeeAddQueue() */
@property (nonatomic , copy , readonly ) LEEConfig LeeAddQueue;

/** 设置 window等级 -> 格式: .LeeWindowLevel(UIWindowLevel) */
@property (nonatomic , copy , readonly ) LEEConfigToFloat LeeWindowLevel;


/** 显示 -> 格式: .LeeShow() */
@property (nonatomic , copy , readonly ) LEEConfig LeeShow;
Expand Down
36 changes: 33 additions & 3 deletions LEEAlert/LEEAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define SCREEN_HEIGHT CGRectGetHeight([[UIScreen mainScreen] bounds])
#define VIEW_WIDTH CGRectGetWidth(self.view.frame)
#define VIEW_HEIGHT CGRectGetHeight(self.view.frame)
#define DEFAULTBORDERWIDTH (1 / [[UIScreen mainScreen] scale])

@interface LEEAlert ()

Expand Down Expand Up @@ -143,6 +144,7 @@ @interface LEEAlertConfigModel ()
@property (nonatomic , assign ) CGFloat modelOpenAnimationDuration;
@property (nonatomic , assign ) CGFloat modelCloseAnimationDuration;
@property (nonatomic , assign ) CGFloat modelBackgroundStyleColorAlpha;
@property (nonatomic , assign ) CGFloat modelWindowLevel;

@property (nonatomic , strong ) UIColor *modelHeaderColor;
@property (nonatomic , strong ) UIColor *modelBackgroundColor;
Expand Down Expand Up @@ -189,6 +191,7 @@ - (instancetype)init
_modelOpenAnimationDuration = 0.3f; //默认打开动画时长
_modelCloseAnimationDuration = 0.2f; //默认关闭动画时长
_modelBackgroundStyleColorAlpha = 0.45f; //自定义背景样式颜色透明度 默认为半透明背景样式 透明度为0.45f
_modelWindowLevel = UIWindowLevelAlert;

_modelActionSheetCancelActionSpaceColor = [UIColor clearColor]; //默认actionsheet取消按钮间隔颜色
_modelActionSheetCancelActionSpaceWidth = 10.0f; //默认actionsheet取消按钮间隔宽度
Expand Down Expand Up @@ -664,6 +667,19 @@ - (LEEConfig)LeeAddQueue{

}

- (LEEConfigToFloat)LeeWindowLevel{

__weak typeof(self) weakSelf = self;

return ^(CGFloat number){

if (weakSelf) weakSelf.modelWindowLevel = number;

return weakSelf;
};

}

- (LEEConfig)LeeShow{

__weak typeof(self) weakSelf = self;
Expand Down Expand Up @@ -938,7 +954,7 @@ - (void)setAction:(LEEAction *)action{

if (action.borderColor) [self setBorderColor:action.borderColor];

if (action.borderWidth) [self setBorderWidth:action.borderWidth < 0.35f ? 0.35f : action.borderWidth];
if (action.borderWidth > 0) [self setBorderWidth:action.borderWidth < DEFAULTBORDERWIDTH ? DEFAULTBORDERWIDTH : action.borderWidth]; else [self setBorderWidth:0.0f];

if (action.image) [self setImage:action.image forState:UIControlStateNormal];

Expand Down Expand Up @@ -1448,6 +1464,18 @@ - (UIWindow *)currentKeyWindow{
return _currentKeyWindow;
}

#pragma mark - 设置竖屏

- (BOOL)shouldAutorotate{

return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{

return UIInterfaceOrientationMaskAll;
}

@end

#pragma mark - Alert
Expand Down Expand Up @@ -1848,7 +1876,7 @@ - (void)configAlert{

if (!action.borderColor) action.borderColor = [UIColor colorWithWhite:0.84 alpha:1.0f];

if (!action.borderWidth) action.borderWidth = 0.35f;
if (!action.borderWidth) action.borderWidth = DEFAULTBORDERWIDTH;

if (!action.borderPosition) action.borderPosition = (self.config.modelActionArray.count == 2 && idx == 0) ? LEEActionBorderPositionTop | LEEActionBorderPositionRight : LEEActionBorderPositionTop;

Expand Down Expand Up @@ -2423,7 +2451,7 @@ - (void)configActionSheet{

if (!action.borderColor) action.borderColor = [UIColor colorWithWhite:0.86 alpha:1.0f];

if (!action.borderWidth) action.borderWidth = 0.35f;
if (!action.borderWidth) action.borderWidth = DEFAULTBORDERWIDTH;

if (!action.height) action.height = 57.0f;

Expand Down Expand Up @@ -2819,6 +2847,8 @@ - (void)show{

[LEEAlert shareManager].viewController.config = self.config;

[LEEAlert shareManager].leeWindow.windowLevel = self.config.modelWindowLevel;

[LEEAlert shareManager].leeWindow.rootViewController = [LEEAlert shareManager].viewController;

[LEEAlert shareManager].leeWindow.hidden = NO;
Expand Down
1 change: 0 additions & 1 deletion LEEAlertDemo/LEEAlertDemo/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

@property (strong, nonatomic) UIWindow *window;


@end

0 comments on commit 6c88c9c

Please sign in to comment.