WFCUConferenceLabelView.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // ConferenceLabelView.m
  3. // WFZoom
  4. //
  5. // Created by Tom Lee on 2021/9/22.
  6. //
  7. #import "WFCUConferenceLabelView.h"
  8. #import "WFCUUtilities.h"
  9. #import "WFCUImage.h"
  10. @interface WFCUConferenceLabelView ()
  11. @property(nonatomic, strong)UIImageView *audioView;
  12. @property(nonatomic, strong)UILabel *nameLabel;
  13. @end
  14. @implementation WFCUConferenceLabelView
  15. //size 100*28
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if(self) {
  19. self.backgroundColor = [UIColor clearColor];
  20. }
  21. return self;
  22. }
  23. - (void)setIsMuteAudio:(BOOL)isMuteAudio {
  24. _isMuteAudio = isMuteAudio;
  25. if(isMuteAudio) {
  26. self.audioView.image = [WFCUImage imageNamed:@"mic_mute"];
  27. } else {
  28. self.volume = _volume;
  29. }
  30. }
  31. - (void)setVolume:(NSInteger)volume {
  32. _volume = volume;
  33. if(self.isMuteAudio)
  34. return;
  35. int v = (int)(volume/1000);
  36. if(v < 0) {
  37. v = 0;
  38. }
  39. if(v > 10) {
  40. v = 10;
  41. }
  42. [UIView animateWithDuration:0.2 animations:^{
  43. self.audioView.image = [WFCUImage imageNamed:[NSString stringWithFormat:@"mic_%d", v]];
  44. }];
  45. }
  46. - (void)setName:(NSString *)name {
  47. _name = name;
  48. self.nameLabel.text = name;
  49. CGSize size = [WFCUUtilities getTextDrawingSize:name font:[UIFont systemFontOfSize:14] constrainedSize:CGSizeMake(1000, 20)];
  50. CGRect frame = self.nameLabel.frame;
  51. frame.size.width = size.width;
  52. self.nameLabel.frame = frame;
  53. frame = self.frame;
  54. frame.size.width = 28 + size.width + 4;
  55. self.frame = frame;
  56. }
  57. - (UIImageView *)audioView {
  58. if (!_audioView) {
  59. _audioView = [[UIImageView alloc] initWithFrame:CGRectMake(4, 4, 20, 20)];
  60. [self addSubview:_audioView];
  61. }
  62. return _audioView;
  63. }
  64. - (UILabel *)nameLabel {
  65. if(!_nameLabel) {
  66. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(28, 4, 48, 20)];
  67. _nameLabel.font = [UIFont systemFontOfSize:14];
  68. _nameLabel.textColor = [UIColor grayColor];
  69. [self addSubview:_nameLabel];
  70. }
  71. return _nameLabel;
  72. }
  73. + (CGSize)sizeOffView {
  74. return CGSizeMake(100, 28);
  75. }
  76. @end