liuzhenxing1118 7 сар өмнө
parent
commit
4fda9ea2fd

+ 73 - 19
artimenring-iOS/Artimenring/Classes/SikeyCommonSDK/Manager/BlackDoorManager.m

@@ -65,7 +65,7 @@
                 [self clearUserClickInfo];
                 break;
             }
-
+            
             //验证头字串不对
             NSString* header = array[0];
             if (![header isEqualToString:KEY_BDM_USERCLICK_HEADER]) {
@@ -113,7 +113,7 @@
             }
             
             //验证通过
-            [self showServerButtons:supperView];
+            [self showBlackDoorView:supperView];
             break;
         }
         default:
@@ -121,7 +121,15 @@
     }
 }
 
-+ (void)showServerButtons:(UIView*)supperView {
++ (void)showBlackDoorView:(UIView*)supperView {
+    UIView* view = [self showBackground:supperView];
+    [self showBackButton:view];
+    [self showServerAllButtons:view];
+    [self showServerTestDevButtons:view];
+    [self showLogButton:view];
+}
+
++ (UIView*)showBackground:(UIView*)supperView {
     UIView* bgview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, BDM_SCREEN_WIDTH, BDM_SCREEN_HEIGHT)];
     [bgview setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]];
     [supperView addSubview:bgview];
@@ -130,7 +138,20 @@
     UIView* view = [[UIView alloc] initWithFrame:CGRectMake(20, (BDM_SCREEN_HEIGHT-Height)/2, BDM_SCREEN_WIDTH - 40, Height)];
     [view setBackgroundColor:[UIColor whiteColor]];
     [bgview addSubview:view];
-    
+    return view;
+}
+
+//关闭
++ (void)showBackButton:(UIView*)view {
+    UIButton* backBtn = [[UIButton alloc] init];
+    [backBtn setTitle:@"关闭" forState:UIControlStateNormal];
+    [backBtn setBackgroundColor:[UIColor redColor]];
+    [backBtn setFrame:CGRectMake((view.frame.size.width - 60), 0, 60, 60)];
+    [backBtn addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    [view addSubview:backBtn];
+}
+
++ (void)showServerAllButtons:(UIView*)view {
     //当前服务器//
     NSInteger serverType = [ServerManager getServerType];
     NSArray* serverNames = [ServerManager getServerNames];
@@ -162,31 +183,64 @@
             [button setFrame:CGRectMake(view.frame.size.width - 150 - 20, 200, 150, 100)];
         }
     }
+}
+
++ (void)showServerTestDevButtons:(UIView*)view {
+    //当前服务器//
+    NSInteger serverType = [ServerManager getServerType];
+    NSArray* serverNames = [ServerManager getServerNames];
     
-    //关闭
-    UIButton* closeBtn = [[UIButton alloc] init];
-    [closeBtn setTitle:@"关闭" forState:UIControlStateNormal];
-    [closeBtn setBackgroundColor:[UIColor redColor]];
-    [closeBtn setFrame:CGRectMake((view.frame.size.width - 60), 0, 60, 60)];
-    [closeBtn addTarget:self action:@selector(closeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
-    [view addSubview:closeBtn];
-    
+    for (NSInteger i = 0; i <= 2; i++) {
+        UIButton* button = [[UIButton alloc] init];
+        button.tag = i;
+        button.titleLabel.lineBreakMode = 0;//这句话很重要,不加这句话加上换行符也没用
+        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+        [button addTarget:self action:@selector(serverButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+        [view addSubview:button];
+        
+        //如果是当前服务器//
+        button.alpha = serverType != i ? 1:0.1;
+        
+        if (i == 0) {
+            [button setTitle:serverNames[i] forState:UIControlStateNormal];
+            [button setBackgroundColor:[UIColor greenColor]];
+            [button setFrame:CGRectMake((view.frame.size.width/2 - 200/2), 70, 200, 100)];
+        }
+        else if (i == 1) {
+            [button setTitle:serverNames[i] forState:UIControlStateNormal];
+            [button setBackgroundColor:[UIColor magentaColor]];
+            [button setFrame:CGRectMake(20, 200, 150, 100)];
+        }
+        else if (i == 2) {
+            [button setTitle:serverNames[i] forState:UIControlStateNormal];
+            [button setBackgroundColor:[UIColor redColor]];
+            [button setFrame:CGRectMake(view.frame.size.width - 150 - 20, 200, 150, 100)];
+        }
+    }
+}
+
+//log
++ (void)showLogButton:(UIView*)view {
+    CGFloat height = 100;
+    UIView* logView = [[UIView alloc] initWithFrame:CGRectMake(0, view.frame.size.height-height, view.frame.size.width, height)];
+    [logView setBackgroundColor:[UIColor clearColor]];
+    [view addSubview:logView];
     
     //底部 log view
-    UIView* dri = [[UIView alloc] initWithFrame:CGRectMake(0, 340, view.frame.size.width, 0.5)];
+    UIView* dri = [[UIView alloc] initWithFrame:CGRectMake(0, 0, logView.frame.size.width, 0.5)];
     [dri setBackgroundColor:[UIColor lightGrayColor]];
-    [view addSubview:dri];
+    [logView addSubview:dri];
     
-    UILabel* logText = [[UILabel alloc] initWithFrame:CGRectMake(20, 355, 200, 30)];
+    UILabel* logText = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 200, 30)];
     [logText setText:@"屏幕上显示日志"];
     [logText setFont:[UIFont systemFontOfSize:17 weight:UIFontWeightBold]];
-    [view addSubview:logText];
+    [logView addSubview:logText];
     
     NSInteger logStatus = [BlackDoorManager getLogStatus];
-    UISwitch* switchBtn = [[UISwitch alloc] initWithFrame:CGRectMake((view.frame.size.width - 50 - 20), 355, 50, 30)];
+    UISwitch* switchBtn = [[UISwitch alloc] initWithFrame:CGRectMake((logView.frame.size.width - 50 - 20), 0, 50, 30)];
     [switchBtn setOn:logStatus == 1];
     [switchBtn addTarget:self action:@selector(clickSwitchButton:) forControlEvents:UIControlEventValueChanged];
-    [view addSubview:switchBtn];
+    [logView addSubview:switchBtn];
 }
 
 + (void)serverButtonClick:(UIButton*)button {
@@ -195,7 +249,7 @@
     [[[button superview] superview] removeFromSuperview];
 }
 
-+ (void)closeButtonClick:(UIButton*)button {
++ (void)backButtonClick:(UIButton*)button {
     [[[button superview] superview] removeFromSuperview];
 }