TYTabPagerBarCell.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // TYTabTitleViewCell.m
  3. // TYPagerControllerDemo
  4. //
  5. // Created by tany on 16/5/4.
  6. // Copyright © 2016年 tanyang. All rights reserved.
  7. //
  8. #import "TYTabPagerBarCell.h"
  9. @interface TYTabPagerBarCell ()
  10. @property (nonatomic, weak) UILabel *titleLabel;
  11. @end
  12. @implementation TYTabPagerBarCell
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. if (self = [super initWithFrame:frame]) {
  16. [self addTabTitleLabel];
  17. }
  18. return self;
  19. }
  20. - (instancetype)initWithCoder:(NSCoder *)aDecoder
  21. {
  22. if (self = [super initWithCoder:aDecoder]) {
  23. [self addTabTitleLabel];
  24. }
  25. return self;
  26. }
  27. - (void)addTabTitleLabel
  28. {
  29. UILabel *titleLabel = [[UILabel alloc]init];
  30. titleLabel.font = [UIFont systemFontOfSize:13];
  31. titleLabel.textColor = [UIColor darkTextColor];
  32. titleLabel.textAlignment = NSTextAlignmentCenter;
  33. [self.contentView addSubview:titleLabel];
  34. _titleLabel = titleLabel;
  35. }
  36. + (NSString *)cellIdentifier {
  37. return @"TYTabPagerBarCell";
  38. }
  39. - (void)layoutSubviews
  40. {
  41. [super layoutSubviews];
  42. _titleLabel.frame = self.contentView.bounds;
  43. }
  44. @end