1 #import "ViewController.h"
2 #import
3
4 static NSString *StartRecord = @"开始";5 static NSString *StopRecord = @"结束";6
7 #if TARGET_IPHONE_SIMULATOR
8 #define SIMULATOR 1
9 #elif TARGET_OS_IPHONE
10 #define SIMULATOR 0
11 #endif
12
13 #define AnimationDuration (0.3)
14
15
16 @interface ViewController ()
17 {18
19 }20 @property (nonatomic, strong)UIButton *btnStart;21 @property (nonatomic, strong)UIButton *btnStop;22 @property (nonatomic, strong)NSTimer *progressTimer;23 @property (nonatomic, strong)UIProgressView *progressView;24 @property (nonatomic, strong)UIActivityIndicatorView *activity;25 @property (nonatomic, strong)UIView *tipView;26 @property (nonatomic, strong)UILabel *lbTip;27 @property (nonatomic, strong)UILabel *lbTime;28
29 @end
30
31 @implementationViewController32
33 - (void)viewDidLoad {34 [super viewDidLoad];35 //Do any additional setup after loading the view, typically from a nib.
36
37 }38
39 - (void)viewDidAppear:(BOOL)animated {40 BOOL isVersionOk =[self isSystemVersionOk];41
42 if (!isVersionOk) {43 NSLog(@"系统版本需要是iOS9.0及以上才支持ReplayKit");44 return;45 }46 if(SIMULATOR) {47 [self showSimulatorWarning];48 return;49 }50
51 UILabel *lb =nil;52 CGSize screenSize =[UIScreen mainScreen].bounds.size;53
54
55 //标题
56 lb = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 140)];57 lb.font = [UIFont boldSystemFontOfSize:32];58 lb.backgroundColor =[UIColor clearColor];59 lb.textColor =[UIColor blackColor];60 lb.textAlignment =NSTextAlignmentCenter;61 lb.numberOfLines = 3;62 lb.text = @"苹果ReplayKit Demo";63 lb.center = CGPointMake(screenSize.width/2, 80);64 [self.view addSubview:lb];65
66 //创建按钮
67 UIButton *btn = [self createButtonWithTitle:StartRecord andCenter:CGPointMake(screenSize.width/2 - 100, 200)];68 [self.view addSubview:btn];69 self.btnStart =btn;70
71 btn = [self createButtonWithTitle:StopRecord andCenter:CGPointMake(screenSize.width/2 + 100, 200)];72 [self.view addSubview:btn];73 self.btnStop =btn;74 [self setButton:btn enabled:NO];75
76 //loading指示
77 UIActivityIndicatorView *activity =[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];78 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 80)];79 [self.view addSubview:view];80 view.backgroundColor =[UIColor redColor];81 view.layer.cornerRadius = 8.0f;82 view.center = CGPointMake(screenSize.width/2, 300);83 activit