recordingView.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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)beginRecordFun
  57. {
  58. [[AudioRecorderManager sharedManager] startRecording];
  59. }
  60. - (void)didClickButFun
  61. {
  62. [[AudioRecorderManager sharedManager] stopRecording];
  63. if (_didClickRecordEndFun) {
  64. _didClickRecordEndFun();
  65. }
  66. }
  67. @end