addAudioToPlayListBottomView.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // addAudioToPlayListBottomView.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/7/15.
  6. //
  7. #import "addAudioToPlayListBottomView.h"
  8. @interface addAudioToPlayListBottomView ()
  9. @property(nonatomic,strong) UIButton*bottomButton;
  10. @end
  11. @implementation addAudioToPlayListBottomView
  12. - (id)initWithFrame:(CGRect)frame{
  13. self = [super initWithFrame:frame];
  14. self.backgroundColor = [UIColor whiteColor];
  15. [self drawAnyView];
  16. return self;
  17. }
  18. - (void)drawAnyView{
  19. // gradient
  20. CAGradientLayer *gl = [CAGradientLayer layer];
  21. gl.frame = CGRectMake(0,0,SCREEN_W,40.f);
  22. gl.startPoint = CGPointMake(0, 0.5);
  23. gl.endPoint = CGPointMake(1, 0.5);
  24. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  25. gl.locations = @[@(0), @(1.0f)];
  26. _bottomButton = [[UIButton alloc] init];
  27. [_bottomButton.layer addSublayer:gl];
  28. [_bottomButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  29. [_bottomButton setTitle:NSLocalizedString(@"NAS_add_audio_to_play_list",nil) forState:UIControlStateNormal];
  30. [_bottomButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  31. _bottomButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
  32. _bottomButton.layer.cornerRadius = 8;
  33. _bottomButton.layer.masksToBounds = YES;
  34. [self addSubview:_bottomButton];
  35. [self setButtonStateFunBy:NO];
  36. [_bottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.right.mas_equalTo(-15);
  38. make.left.mas_equalTo(15);
  39. make.height.mas_equalTo(40);
  40. make.top.mas_equalTo(10);
  41. }];
  42. }
  43. - (void)didClickButFun:(UIButton*)but
  44. {
  45. NSInteger tag = but.tag;
  46. if(_didClickButtonFun){
  47. _didClickButtonFun(tag);
  48. }
  49. }
  50. - (void)setButtonStateFunBy:(BOOL)canClick
  51. {
  52. CGFloat alpha = canClick ? 1.0 : 0.5;
  53. _bottomButton.enabled = canClick;
  54. _bottomButton.alpha = alpha;
  55. }
  56. @end