RQTabBar.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // RQTabBar.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/14.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. // 自定义系统的TabBar,解决TabBar顶部的细线高度问题
  8. #import "RQTabBar.h"
  9. @interface RQTabBar ()
  10. /// divider
  11. @property (nonatomic, readwrite, weak) UIView *divider;
  12. @end
  13. @implementation RQTabBar
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. /// 去掉tabBar的分割线,以及背景图片
  18. [self setShadowImage:[UIImage new]];
  19. [self setBackgroundImage:[UIImage yy_imageWithColor:UIColor.whiteColor]];
  20. self.backgroundColor = UIColor.whiteColor;
  21. /// 添加细线,
  22. UIView *divider = [[UIView alloc] init];
  23. divider.backgroundColor = RQColor(167.0f, 167.0f, 170.0f);
  24. [self addSubview:divider];
  25. self.divider = divider;
  26. if (@available(iOS 13.0, *)) {
  27. self.tintColor = RQ_MAIN_COLOR;
  28. } else {
  29. self.tintColor = [UIColor whiteColor];
  30. }
  31. }
  32. return self;
  33. }
  34. #pragma mark - 布局
  35. - (void)layoutSubviews {
  36. [super layoutSubviews];
  37. [self bringSubviewToFront:self.divider];
  38. self.divider.rq_height = RQGlobalBottomLineHeight;
  39. self.divider.rq_width = RQ_SCREEN_WIDTH;
  40. }
  41. @end