MJExampleWindow.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // MJExampleWindow.m
  3. // MJRefreshExample
  4. //
  5. // Created by MJ Lee on 15/8/17.
  6. // Copyright (c) 2015年 小码哥. All rights reserved.
  7. //
  8. #import "MJExampleWindow.h"
  9. @implementation MJExampleWindow
  10. static UIWindow *window_;
  11. + (void)show
  12. {
  13. window_ = [[UIWindow alloc] init];
  14. CGFloat width = 150;
  15. CGFloat x = [UIScreen mainScreen].bounds.size.width - width - 10;
  16. window_.frame = CGRectMake(x, 0, width, 25);
  17. window_.windowLevel = UIWindowLevelAlert;
  18. window_.hidden = NO;
  19. window_.alpha = 0.5;
  20. UISegmentedControl *control = [[UISegmentedControl alloc] initWithItems:@[@"示例1", @"示例2", @"示例3"]];
  21. control.tintColor = [UIColor orangeColor];
  22. control.frame = window_.bounds;
  23. control.selectedSegmentIndex = 0;
  24. [control addTarget:self action:@selector(contorlSelect:) forControlEvents:UIControlEventValueChanged];
  25. [window_ addSubview:control];
  26. }
  27. + (void)contorlSelect:(UISegmentedControl *)control
  28. {
  29. UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
  30. keyWindow.rootViewController = [keyWindow.rootViewController.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%zd", control.selectedSegmentIndex]];
  31. }
  32. @end