酷店

KDPNavBar.m 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // KDPNavBar.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/4.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPNavBar.h"
  9. @implementation KDPNavBar
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self =[super initWithFrame:frame];
  13. if (self) {
  14. [self addSubview:self.navTitleLabel];
  15. [self addSubview:self.lineView];
  16. [self.navTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.left.mas_equalTo(50);
  18. make.right.mas_equalTo(-50);
  19. make.top.mas_equalTo(KDStatusHeight);
  20. make.height.mas_equalTo(44);
  21. }];
  22. [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.top.mas_equalTo(self.mas_bottom).offset(1);
  24. make.left.right.mas_equalTo(0);
  25. make.height.mas_equalTo(1);
  26. }];
  27. }
  28. return self;
  29. }
  30. -(void)setLineViewWithHidden:(BOOL)status
  31. {
  32. self.lineView.hidden=status;
  33. }
  34. -(void)addleftReturnButton:(id)target selector:(SEL)selector
  35. {
  36. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, KDStatusHeight, 44, 44)];
  37. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  38. [returnBtn addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
  39. [self addSubview:returnBtn];
  40. }
  41. -(UILabel *)navTitleLabel
  42. {
  43. if (!_navTitleLabel) {
  44. _navTitleLabel=[[UILabel alloc]init];
  45. _navTitleLabel.textAlignment=NSTextAlignmentCenter;
  46. _navTitleLabel.font=[UIFont systemFontOfSize:17];
  47. _navTitleLabel.textColor=[UIColor whiteColor];
  48. }
  49. return _navTitleLabel;
  50. }
  51. -(UIView *)lineView
  52. {
  53. if (!_lineView) {
  54. _lineView=[[UIView alloc]init];
  55. _lineView.backgroundColor=[UIColor colorWithHexString:LineColor];
  56. _lineView.hidden=YES;
  57. }
  58. return _lineView;
  59. }
  60. @end