ToneTuningBodyView.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // ToneTuningBodyView.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2022/10/14.
  6. //
  7. #import "ToneTuningBodyView.h"
  8. @interface ToneTuningBodyView ()
  9. @property (weak, nonatomic) IBOutlet UIView *minusView;
  10. @property (weak, nonatomic) IBOutlet UIButton *minusButton;
  11. @property (weak, nonatomic) IBOutlet UIView *addView;
  12. @property (weak, nonatomic) IBOutlet UIButton *addButton;
  13. @end
  14. @implementation ToneTuningBodyView
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. CAGradientLayer *layer = [self createGradientLayerFromColor:HexRGB(0x323D50) startPoint:CGPointMake(0.5, 0) endColor:HexRGB(0x1C2331) endPoint:CGPointMake(0.5, 1) bounds:CGRectMake(0, 0, KPortraitWidth - 28, 170)];
  18. layer.cornerRadius = 11.0f;
  19. layer.masksToBounds = YES;
  20. [self.pitchBgView.layer addSublayer:layer];
  21. CAGradientLayer *minusLayer = [self createGradientLayerFromColor:HexRGB(0x3C495F) startPoint:CGPointMake(0.5, 0) endColor:HexRGB(0x1C2331) endPoint:CGPointMake(0.5, 1) bounds:CGRectMake(0, 0, 50, 31)];
  22. minusLayer.cornerRadius = 15.5f;
  23. minusLayer.masksToBounds = YES;
  24. [self.minusView.layer addSublayer:minusLayer];
  25. CAGradientLayer *addViewLayer = [self createGradientLayerFromColor:HexRGB(0x3C495F) startPoint:CGPointMake(0.5, 0) endColor:HexRGB(0x1C2331) endPoint:CGPointMake(0.5, 1) bounds:CGRectMake(0, 0, 50, 31)];
  26. addViewLayer.cornerRadius = 15.5f;
  27. addViewLayer.masksToBounds = YES;
  28. [self.addView.layer addSublayer:addViewLayer];
  29. self.transferView.hidden = YES;
  30. }
  31. + (instancetype)shareInstance {
  32. ToneTuningBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"ToneTuningBodyView" owner:nil options:nil] firstObject];
  33. return view;
  34. }
  35. - (CAGradientLayer *)createGradientLayerFromColor:(UIColor *)fromColor startPoint:(CGPoint)startPoint endColor:(UIColor *)endColor endPoint:(CGPoint)endPoint bounds:(CGRect)bounds {
  36. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  37. gradientLayer.colors = @[(__bridge id)fromColor.CGColor, (__bridge id)endColor.CGColor];
  38. gradientLayer.startPoint = startPoint;
  39. gradientLayer.endPoint = endPoint;
  40. gradientLayer.frame = bounds;
  41. gradientLayer.locations = @[@(0),@(1.0f)];
  42. return gradientLayer;
  43. }
  44. /*
  45. // Only override drawRect: if you perform custom drawing.
  46. // An empty implementation adversely affects performance during animation.
  47. - (void)drawRect:(CGRect)rect {
  48. // Drawing code
  49. }
  50. */
  51. @end