MHBottomView.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // MHBottomView.m
  3. // TXLiteAVDemo_UGC
  4. //
  5. // Created by Apple on 2021/2/27.
  6. // Copyright © 2021 Tencent. All rights reserved.
  7. //
  8. #import "MHBottomView.h"
  9. @interface MHBottomView ()
  10. @property (nonatomic, strong) UIButton * takePhotoBtn;
  11. @property (nonatomic, strong) UIButton * packUpBtn;
  12. @end
  13. @implementation MHBottomView
  14. - (instancetype)initWithFrame:(CGRect)frame
  15. {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. [self createSubviews];
  19. }
  20. return self;
  21. }
  22. #pragma mark - 穿透点击
  23. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  24. UIView *hitView = [super hitTest:point withEvent:event];
  25. if (hitView == self) {
  26. return nil; // 此处返回空即不相应任何事件
  27. }
  28. return hitView;
  29. }
  30. #pragma mark - 创建子视图
  31. - (void)createSubviews{
  32. CGFloat width = self.frame.size.width;
  33. CGFloat takePhotoWidth = 50;
  34. CGFloat takePhotoHeight = takePhotoWidth;
  35. CGFloat packUpWidth = 17;
  36. CGFloat packUpHeight = packUpWidth/11*6;
  37. CGFloat leftMargin = 45;
  38. _takePhotoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  39. _takePhotoBtn.frame = CGRectMake((width-takePhotoWidth)/2, 0, takePhotoWidth, takePhotoHeight);
  40. _takePhotoBtn.tag = 1000;
  41. UIImage * cameraImage = BundleImg(@"beautyCamera");
  42. [_takePhotoBtn setBackgroundImage:cameraImage forState:UIControlStateNormal];
  43. [_takePhotoBtn addTarget:self action:@selector(cameraAction:) forControlEvents:UIControlEventTouchUpInside];
  44. [self addSubview:_takePhotoBtn];
  45. UIImage *imgClose = BundleImg(@"packUp");
  46. UIImageView *imgCloseView = [[UIImageView alloc] initWithImage:imgClose];
  47. imgCloseView.frame = CGRectMake(leftMargin, (takePhotoHeight - packUpHeight)/2, 20, 20);
  48. imgCloseView.contentMode = UIViewContentModeScaleAspectFit;
  49. [self addSubview:imgCloseView];
  50. _packUpBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  51. _packUpBtn.frame = CGRectMake(leftMargin, 5, 60, 60);
  52. _packUpBtn.tag = 1001;
  53. [_packUpBtn addTarget:self action:@selector(cameraAction:) forControlEvents:UIControlEventTouchUpInside];
  54. [self addSubview:_packUpBtn];
  55. NSString *currentLan = [[NSUserDefaults standardUserDefaults] valueForKey:kLanguage];
  56. if ([currentLan isEqualToString:kLanguage_EN]) {
  57. cameraImage = FoxBundleImg(@"camera_fox");
  58. [_takePhotoBtn setBackgroundImage:cameraImage forState:UIControlStateNormal];
  59. imgClose = FoxBundleImg(@"closeArrow");
  60. imgCloseView.image = imgClose;
  61. }
  62. }
  63. //- (void)setIsSticker:(BOOL)isSticker{
  64. // _isSticker = isSticker;
  65. // //_packUpBtn.hidden = _isSticker;
  66. //}
  67. - (void)cameraAction:(UIButton*)sender{
  68. if (sender.tag == 1000) {
  69. _clickBtn(YES);
  70. }else{
  71. _clickBtn(NO);
  72. }
  73. }
  74. @end