一:创建window添加上面。添加在新建window上
(1).@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UIButton *flButton;
//悬浮按钮所处的顶端UIWindow
// _window = [[UIWindow alloc] initWithFrame:CGRectMake(screenWidth*0.5 - 36, screenHeight - 122, 72, 72)];
// _window.layer.cornerRadius = 36;
// _window.layer.masksToBounds = YES;
// //使得新建window在最顶端
// _window.windowLevel = UIWindowLevelAlert + 1;
// _window.backgroundColor = [UIColor clearColor];
// [_window addSubview:_flButton];
// //显示window
// [_window makeKeyAndVisible];
(2).移除window[_window resignKeyWindow];
_window = nil;
二:获取单例window,然后将button添加上面。移除时让button隐藏。 @property ( nonatomic , strong ) UIWindow *window;_window = [[UIApplication sharedApplication].windows lastObject];
// 添加到窗口
[_window addSubview:_flButton];