模拟/真实数据切换
@interface SceneDelegate ()
@property (nonatomic, strong) JCMockSwitchView *mockView;///<
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
self.window.frame = windowScene.coordinateSpace.bounds;
self.window.rootViewController = [ViewController new];
[self.window makeKeyAndVisible];
[self addMockView];
}
- (void)addMockView {
// DEBUG模式下显示模拟数据切换按钮
self.mockView = [[JCMockSwitchView alloc] initWithFrame:CGRectMake(10, 20*5, 0, 0)];
#ifdef DEBUG
[[UIApplication sharedApplication].keyWindow addSubview:self.mockView];
#endif
}
@end