KSWebNavView.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // KSWebNavView.m
  3. // StudentDaya
  4. //
  5. // Created by Kyle on 2021/12/27.
  6. // Copyright © 2021 DayaMusic. All rights reserved.
  7. //
  8. #import "KSWebNavView.h"
  9. @interface KSWebNavView ()
  10. @end
  11. @implementation KSWebNavView
  12. - (instancetype)init {
  13. self = [super init];
  14. if (self) {
  15. [self configUI];
  16. }
  17. return self;
  18. }
  19. - (void)configUI {
  20. self.backgroundColor = [UIColor whiteColor];
  21. UILabel *headLabel = [[UILabel alloc] init];
  22. headLabel.textColor = HexRGB(0x000000);
  23. headLabel.font = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
  24. headLabel.textAlignment = NSTextAlignmentCenter;
  25. self.topTitleLabel = headLabel;
  26. [self addSubview:self.topTitleLabel];
  27. [self.topTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.bottom.mas_equalTo(self.mas_bottom);
  29. make.centerX.mas_equalTo(self.mas_centerX);
  30. make.left.mas_equalTo(self.mas_left).offset(70);
  31. make.right.mas_equalTo(self.mas_right).offset(-70);
  32. make.height.mas_equalTo(44);
  33. }];
  34. }
  35. - (void)createRightButton:(NSString *)imageName target:(id)target action:(SEL)action {
  36. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
  37. [rightButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  38. [rightButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
  39. [self addSubview:rightButton];
  40. [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.right.bottom.mas_equalTo(self);
  42. make.width.height.mas_equalTo(44);
  43. }];
  44. }
  45. /*
  46. // Only override drawRect: if you perform custom drawing.
  47. // An empty implementation adversely affects performance during animation.
  48. - (void)drawRect:(CGRect)rect {
  49. // Drawing code
  50. }
  51. */
  52. @end