酷店

KDPNavBar.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. [returnBtn bringSubviewToFront:[UIApplication sharedApplication].keyWindow];
  40. [self addSubview:returnBtn];
  41. }
  42. -(UILabel *)navTitleLabel
  43. {
  44. if (!_navTitleLabel) {
  45. _navTitleLabel=[[UILabel alloc]init];
  46. _navTitleLabel.textAlignment=NSTextAlignmentCenter;
  47. _navTitleLabel.font=[UIFont systemFontOfSize:17];
  48. _navTitleLabel.textColor=[UIColor whiteColor];
  49. }
  50. return _navTitleLabel;
  51. }
  52. -(UIView *)lineView
  53. {
  54. if (!_lineView) {
  55. _lineView=[[UIView alloc]init];
  56. _lineView.backgroundColor=[UIColor colorWithHexString:LineColor];
  57. _lineView.hidden=YES;
  58. }
  59. return _lineView;
  60. }
  61. @end