recordingView.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // recordingView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2025/3/28.
  6. //
  7. #import "recordingView.h"
  8. #import "AudioRecorderManager.h"
  9. @implementation recordingView
  10. - (id)initWithFrame:(CGRect)frame{
  11. self = [super initWithFrame:frame];
  12. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  13. [self drawAnyView];
  14. return self;
  15. }
  16. -(void)drawAnyView{
  17. UIView *whiteBgView = [[UIView alloc] init];
  18. whiteBgView.backgroundColor = [UIColor whiteColor];
  19. [self addSubview:whiteBgView];
  20. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.left.mas_equalTo(0.f);
  22. make.height.mas_equalTo(238.f + AdaptTabHeight);
  23. make.right.mas_equalTo(0.f);
  24. make.bottom.mas_equalTo(0.f);
  25. }];
  26. /*上圆角*/
  27. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W, 238.f + AdaptTabHeight)
  28. byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
  29. cornerRadii:CGSizeMake(12, 12)];
  30. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  31. maskLayer.frame = CGRectMake(0, 0, SCREEN_W, 238.f + AdaptTabHeight);
  32. maskLayer.path = maskPath.CGPath;
  33. whiteBgView.layer.mask = maskLayer;
  34. UIButton *recordBut = [[UIButton alloc] init];
  35. [recordBut setBackgroundImage:[UIImage imageNamed:@"white_record_end_icon"] forState:UIControlStateNormal];
  36. [recordBut addTarget:self action:@selector(didClickButFun) forControlEvents:UIControlEventTouchUpInside];
  37. [whiteBgView addSubview:recordBut];
  38. [recordBut mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.width.mas_equalTo(78.f);
  40. make.height.mas_equalTo(78.f);
  41. make.centerX.mas_equalTo(0.f);
  42. make.bottom.mas_equalTo(-12.f - AdaptTabHeight);
  43. }];
  44. //
  45. UIImageView *recordingTipImageView = [[UIImageView alloc] init];
  46. recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
  47. [whiteBgView addSubview:recordingTipImageView];
  48. [recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.width.mas_equalTo(323.f*AUTOSCALE);
  50. make.height.mas_equalTo(52.f*AUTOSCALE);
  51. make.centerX.mas_equalTo(0.f);
  52. make.bottom.equalTo(recordBut.mas_top).offset(-20);
  53. }];
  54. }
  55. #pragma mark 开始录音
  56. - (void)beginRecordFunWith:(NSInteger)curIndex;
  57. {
  58. [AudioRecorderManager sharedManager].curRecordName = [[NSString alloc] initWithFormat:@"record%ld.m4a",curIndex];
  59. [[AudioRecorderManager sharedManager] startRecording];
  60. }
  61. - (void)didClickButFun
  62. {
  63. [[AudioRecorderManager sharedManager] stopRecording];
  64. if (_didClickRecordEndFun) {
  65. _didClickRecordEndFun();
  66. }
  67. }
  68. @end