| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- //
- // FloatingWindow.m
- // AIIM
- //
- // Created by gan on 2025/7/9.
- //
- #import <Foundation/Foundation.h>
- #import "FloatingWindow.h"
- #import "APPLockView.h"
- #import "FloatJSWindow.h"
- #import "AppDelegate.h"
- @interface FloatingWindow ()
- @property (nonatomic, strong) APPLockView *lockView;
- @property (nonatomic, strong) UIView *JSWindow;
- @property (nonatomic, assign) CGRect innitframe;
- @property (nonatomic, strong) UIButton *floadBT;
- @property (nonatomic, strong) UIView *floadNotView;
- @end
- @implementation FloatingWindow
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- _innitframe = frame;
- self.windowLevel = UIWindowLevelAlert + 1;
- self.backgroundColor = [UIColor clearColor];
- self.rootViewController = [UIViewController new];
-
- }
- return self;
- }
- - (void)show:(NSInteger)type{
- self.hidden = NO;
- [self makeKeyAndVisible];
- if(type==1){
- [self initlockView];
- }
-
- }
- - (void)hide {
- self.hidden = YES;
- }
- -(void)initlockView{
- if(_JSWindow){
- _JSWindow.hidden=YES;
- }
- if(_lockView){
- _lockView.hidden=NO;
- return;
- }
- else{
- weakSelf(self);
- _lockView=[[APPLockView alloc] initWithFrame:self.frame];
- _lockView.onShide = ^{
- [weakself hide];
- };
- [self addSubview:_lockView];
- }
- }
- - (void)showView:(UIView *)view{
- self.hidden = NO;
- if(_lockView){
- _lockView.hidden=YES;
- }
- if(_JSWindow){
- _JSWindow.hidden=NO;
- NSLog(@"_JSWindow.hidden=NO");
- return;
- }
- else{
- _JSWindow=view;
- NSLog(@"__JSWindow=view");
- [self addSubview:_JSWindow];
- }
- }
- -(void)viewInFload:(NSInteger)type{
- if(type==0){
- self.frame=_innitframe;
- _floadNotView.hidden = YES;
- if(_JSWindow){
- _JSWindow.hidden=NO;
- }
- }
- else if(type==1 || type==2){
- if(_JSWindow){
- _JSWindow.hidden=YES;
- }
- if(_lockView){
- _lockView.hidden=YES;
- }
- [self initfloadNotView:type];
- self.frame =CGRectMake(100, 180, 70, 70);
- }
- }
- -(void)floadBTsel{
- NSLog(@"floadBTsel----------");
- [self viewInFload:0];
- UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
- [keyWindow endEditing:YES];
- }
- -(void)initfloadNotView:(NSInteger)type{
- NSString *icon = @"Cyuyinth";
- if (type==2) {
- icon = @"Cshipinth";
- }
-
- if(_floadNotView){
- [_floadBT setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
- _floadNotView.hidden=NO;
- return;
- }
- else{
- _floadNotView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
- _floadNotView.backgroundColor = globalColor(GCTypeOrangeR);
- _floadNotView.layer.cornerRadius = 8.0f;
- [self addSubview:_floadNotView];
- _floadBT = [UIButton buttonWithType:UIButtonTypeCustom];
- [_floadBT setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
- [_floadNotView addSubview:_floadBT];
- [_floadBT addTarget:self action:@selector(floadBTsel) forControlEvents:UIControlEventTouchUpInside];
- [_floadBT mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(50, 50));
- make.top.mas_equalTo(10);
- make.left.mas_equalTo(10);
- }];
- }
- }
- @end
|