TabControl.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // TabControl.m
  3. // model
  4. //
  5. // Created by Drew on 2018/11/1.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. //
  8. #import "TabControl.h"
  9. @interface TabControl()
  10. @property (weak, nonatomic) IBOutlet UIView *indicator;
  11. @end
  12. @implementation TabControl
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. if (self = [super initWithFrame:frame]) {
  15. [self initView];
  16. }
  17. return self;
  18. }
  19. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  20. if (self = [super initWithCoder:aDecoder]) {
  21. [self initView];
  22. }
  23. return self;
  24. }
  25. - (void) initView {
  26. NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  27. NSString *className = NSStringFromClass([self class]);
  28. UIView *view = [[bundle loadNibNamed:className owner:self options:nil] firstObject];
  29. view.frame = self.bounds;
  30. view.backgroundColor = [UIColor clearColor];
  31. [self addSubview:view];
  32. self.clipsToBounds = YES;
  33. }
  34. -(void)layoutSubviews {
  35. self.layer.cornerRadius = self.frame.size.height / 2;
  36. self.indicator.layer.cornerRadius = self.frame.size.height / 2;
  37. }
  38. @end