UIWindow+BBALevelManager.h 1.49 KB
//
//  UIWindow+BBALevelManager.h
//  rotation
//
//  Created by liuchengqing01 on 2017/9/29.
//  Copyright © 2017年 baidu. All rights reserved.
//

#import <UIKit/UIKit.h>

/*
 windowLevel            default = 0.0
 UIWindowLevelNormal    0
 UIWindowLevelStatusBar 1000
 UIWindowLevelAlert     2000
 */
// 自定义level尽量在UIWindowLevelAlert以下避免影响权限alert的使用
typedef NS_ENUM(NSUInteger, BBAWindowLevel) {
    BBAWindowLevelSplash        = 1400, //闪屏
    BBAWindowLevelToast         = 1300, //toast提醒
    BBAWindowLevelAlert         = 1200, //弹窗提醒
    BBAWindowLevelSuspension    = 1100, //悬浮窗(新特性)
    BBAWindowLevelStatusBar     = 1000, //状态栏
	BBAWindowLevelAudioPlayer	= 999,	//全局音频播放器
    BBAWindowLevelNightMask     = 1,    //夜间模式(临时定为1与现有逻辑一致)
    BBAWindowLevelNormal        = 0,
};

/*
 不建议使用makeKeyAndVisible,
 1.keyWindow主要负责接受键盘事件与非点击事件, 而点击事件会根据window的leave进行响应
 2.非keyWindow上的textField等也可以通过点击与代码设置为firstRespond
 3.keyWindow同一时间只允许存在一个, 抢占keyWindow导致[UIApplication sharedApplication].keyWindow取不到app的主Window
 */

@interface UIWindow (BBALevelManager)

- (void)bba_show;

- (void)bba_disappear;

- (BOOL)bba_isShowed;

- (void)bba_showAsLevel:(BBAWindowLevel)level;

- (void)bba_showAboveWindow:(UIWindow *)window;

- (void)bba_showBlowWindow:(UIWindow *)window;

@end