app内录屏开发 ios_【原创】苹果内置录屏SDK-ReplayKit库的使用说明

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值