123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // recordingView.m
- // 双子星云手机
- //
- // Created by xd h on 2025/3/28.
- //
- #import "recordingView.h"
- #import "AudioRecorderManager.h"
- @interface recordingView ()
- @property(nonatomic,strong)UILabel * titlelabel;
- @property(nonatomic,strong)UILabel * timerlabel;
- @property(nonatomic,assign)NSInteger second;
- @property(nonatomic,strong)NSTimer * secondTimer;
- @end
- @implementation recordingView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
-
- self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
- [self drawAnyView];
-
- return self;
- }
- -(void)drawAnyView{
-
- UIView *whiteBgView = [[UIView alloc] init];
- whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:whiteBgView];
-
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0.f);
- make.height.mas_equalTo(238.f + AdaptTabHeight);
- make.right.mas_equalTo(0.f);
- make.bottom.mas_equalTo(0.f);
- }];
-
- /*上圆角*/
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W, 238.f + AdaptTabHeight)
- byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = CGRectMake(0, 0, SCREEN_W, 238.f + AdaptTabHeight);
- maskLayer.path = maskPath.CGPath;
- whiteBgView.layer.mask = maskLayer;
- UIButton *recordBut = [[UIButton alloc] init];
- [recordBut setBackgroundImage:[UIImage imageNamed:@"white_record_end_icon"] forState:UIControlStateNormal];
- [recordBut addTarget:self action:@selector(didClickButFun) forControlEvents:UIControlEventTouchUpInside];
- [whiteBgView addSubview:recordBut];
-
- [recordBut mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(78.f);
- make.height.mas_equalTo(78.f);
- make.centerX.mas_equalTo(0.f);
- make.bottom.mas_equalTo(-12.f - AdaptTabHeight);
- }];
-
- //
- UIImageView *recordingTipImageView = [[UIImageView alloc] init];
- recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
- [whiteBgView addSubview:recordingTipImageView];
-
- [recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(323.f*AUTOSCALE);
- make.height.mas_equalTo(52.f*AUTOSCALE);
- make.centerX.mas_equalTo(0.f);
- make.bottom.equalTo(recordBut.mas_top).offset(-20);
- }];
-
-
- //标题
- _titlelabel = [[UILabel alloc] init];
- [whiteBgView addSubview:_titlelabel];
- _titlelabel.font = [UIFont systemFontOfSize:14.f];
- _titlelabel.textAlignment = NSTextAlignmentCenter;
- [_titlelabel setTextColor:HW0A132BColor];
- [_titlelabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(12.0);
- make.top.mas_equalTo(15.0);
- make.height.mas_equalTo(20.0);
- make.right.mas_equalTo(-12.f);
- }];
-
- _timerlabel = [[UILabel alloc] init];
- [whiteBgView addSubview:_timerlabel];
- _timerlabel.font = [UIFont systemFontOfSize:12.f];
- _timerlabel.text = @"00:00:00";
- _timerlabel.textAlignment = NSTextAlignmentCenter;
- [_timerlabel setTextColor:[UIColor hwColor:@"979797"]];
- [_timerlabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(12.0);
- make.top.mas_equalTo(15.0);
- make.height.mas_equalTo(20.0);
- make.right.mas_equalTo(-12.f);
- }];
-
- }
- #pragma mark 开始录音
- - (void)beginRecordFunWith:(NSInteger)curIndex;
- {
- NSString *curName = [[NSString alloc] initWithFormat:@"record%ld.m4a",curIndex];
- _titlelabel.text = curName;
- [AudioRecorderManager sharedManager].curRecordName = curName;
- [[AudioRecorderManager sharedManager] startRecording];
-
- //_secondTimer in
- _secondTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:_secondTimer forMode:NSRunLoopCommonModes];
- }
- #pragma mark 一秒一次的timer检测
- - (void)timerChange{
-
- }
- - (void)didClickButFun
- {
- [[AudioRecorderManager sharedManager] stopRecording];
- if (_didClickRecordEndFun) {
- _didClickRecordEndFun();
- }
- }
- @end
|