FUExportVideoView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // FUExportVideoView.m
  3. // FULiveDemo
  4. //
  5. // Created by 项林平 on 2022/10/21.
  6. //
  7. #import "FUExportVideoView.h"
  8. #import "FUProgressHUD.h"
  9. @interface FUExportVideoView ()
  10. @property (nonatomic, strong) UIButton *cancelButton;
  11. @property (nonatomic, strong) FUProgressHUD *progressHUD;
  12. @end
  13. @implementation FUExportVideoView
  14. #pragma mark - Initializer
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
  19. [self configureUI];
  20. }
  21. return self;
  22. }
  23. #pragma mark - UI
  24. - (void)configureUI {
  25. UILabel *label = [[UILabel alloc] init];
  26. label.text = FULocalizedString(@"exporting_video_tips");
  27. label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
  28. label.textColor = [UIColor whiteColor];
  29. label.textAlignment = NSTextAlignmentCenter;
  30. label.numberOfLines = 0;
  31. [self addSubview:label];
  32. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.leading.equalTo(self.mas_leading).mas_offset(20);
  34. make.trailing.equalTo(self.mas_trailing).mas_offset(-20);
  35. make.centerY.equalTo(self.mas_centerY).mas_offset(-3);
  36. }];
  37. [self addSubview:self.cancelButton];
  38. [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.centerX.equalTo(self);
  40. make.top.equalTo(label.mas_bottom).mas_offset(30);
  41. make.size.mas_offset(CGSizeMake(84, 28));
  42. }];
  43. [self addSubview:self.progressHUD];
  44. [self.progressHUD mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.bottom.equalTo(label.mas_top).mas_offset(-26);
  46. make.centerX.equalTo(self);
  47. make.size.mas_offset(CGSizeMake(66, 66));
  48. }];
  49. }
  50. #pragma mark - Instance methods
  51. - (void)setExportProgress:(CGFloat)progress {
  52. [self.progressHUD setProgress:progress];
  53. }
  54. #pragma mark - Event response
  55. - (void)cancelAction {
  56. if (self.delegate && [self.delegate respondsToSelector:@selector(exportVideoViewDidClickCancel)]) {
  57. [self.delegate exportVideoViewDidClickCancel];
  58. }
  59. }
  60. #pragma mark - Getters
  61. - (FUProgressHUD *)progressHUD {
  62. if (!_progressHUD) {
  63. _progressHUD = [[FUProgressHUD alloc] initWithFrame:CGRectMake(0, 0, 66, 66)];
  64. }
  65. return _progressHUD;
  66. }
  67. - (UIButton *)cancelButton {
  68. if (!_cancelButton) {
  69. _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
  70. _cancelButton.frame = CGRectMake(0, 0, 84, 28);
  71. _cancelButton.layer.masksToBounds = YES;
  72. _cancelButton.layer.cornerRadius = 14.f;
  73. _cancelButton.layer.borderWidth = 1;
  74. _cancelButton.layer.borderColor = [UIColor whiteColor].CGColor;
  75. [_cancelButton setTitle:FULocalizedString(@"取消") forState:UIControlStateNormal];
  76. [_cancelButton addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
  77. }
  78. return _cancelButton;
  79. }
  80. @end