ChatAudioRecordNoticeView.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // ChatAudioRecordNoticeView.m
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "ChatAudioRecordNoticeView.h"
  9. @implementation ChatAudioRecordNoticeView
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self)
  14. {
  15. self.frame = CGRectMake(0, 0, NIMKit_ViewWidth, NIMKit_ViewHeight);
  16. _backgrounView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_input_record_indicator"]];
  17. [self addSubview:_backgrounView];
  18. _tipBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_input_record_indicator_cancel"]];
  19. _tipBackgroundView.hidden = YES;
  20. _tipBackgroundView.frame = CGRectMake(0, NIMKit_ViewHeight - CGRectGetHeight(_tipBackgroundView.bounds), NIMKit_ViewWidth, CGRectGetHeight(_tipBackgroundView.bounds));
  21. [self addSubview:_tipBackgroundView];
  22. _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  23. _timeLabel.font = [UIFont boldSystemFontOfSize:NIMKit_TimeFontSize];
  24. _timeLabel.textColor = [UIColor whiteColor];
  25. _timeLabel.textAlignment = NSTextAlignmentCenter;
  26. _timeLabel.text = @"00:00";
  27. [self addSubview:_timeLabel];
  28. _tipLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  29. _tipLabel.font = [UIFont systemFontOfSize:NIMKit_TipFontSize];
  30. _tipLabel.textColor = [UIColor whiteColor];
  31. _tipLabel.textAlignment = NSTextAlignmentCenter;
  32. _tipLabel.text = ASLocalizedString(@"手指上滑,取消发送");
  33. [self addSubview:_tipLabel];
  34. self.mstatus = 1;
  35. }
  36. return self;
  37. }
  38. - (void)setRecordTime:(NSTimeInterval)recordTime
  39. {
  40. NSInteger minutes = (NSInteger) recordTime / 60;
  41. NSInteger seconds = (NSInteger) recordTime % 60;
  42. _timeLabel.text = [NSString stringWithFormat:@"%02zd:%02zd", minutes, seconds];
  43. }
  44. - (void)setMstatus:(int)mstatus
  45. {
  46. if (mstatus == 1)
  47. {
  48. [self setRecordTime:0];
  49. }
  50. else if (mstatus == 2)
  51. {
  52. _tipLabel.text = ASLocalizedString(@"松开手指,取消发送");
  53. _tipBackgroundView.hidden = NO;
  54. }
  55. else
  56. {
  57. _tipLabel.text = ASLocalizedString(@"手指上滑,取消发送");
  58. _tipBackgroundView.hidden = YES;
  59. }
  60. _mstatus = mstatus;
  61. }
  62. - (void)layoutSubviews
  63. {
  64. CGSize size = [_timeLabel sizeThatFits:CGSizeMake(NIMKit_ViewWidth, MAXFLOAT)];
  65. _timeLabel.frame = CGRectMake(0, 36, NIMKit_ViewWidth, size.height);
  66. size = [_tipLabel sizeThatFits:CGSizeMake(NIMKit_ViewWidth, MAXFLOAT)];
  67. _tipLabel.frame = CGRectMake(0, NIMKit_ViewHeight - 10 - size.height, NIMKit_ViewWidth, size.height);
  68. }
  69. @end