JXCategoryTitleView.h 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // JXCategoryView.h
  3. // UI系列测试
  4. //
  5. // Created by jiaxin on 2018/3/15.
  6. // Copyright © 2018年 jiaxin. All rights reserved.
  7. //
  8. #import "JXCategoryIndicatorView.h"
  9. #import "JXCategoryTitleCell.h"
  10. #import "JXCategoryTitleCellModel.h"
  11. #import "JXCategoryViewDefines.h"
  12. @class JXCategoryTitleView;
  13. @protocol JXCategoryTitleViewDataSource <NSObject>
  14. @optional
  15. // 返回title的个数,如果实现此代理,则titles属性无效
  16. - (NSInteger)numberOfTitleView:(JXCategoryTitleView *)titleView;
  17. // 返回index对应的标题
  18. - (NSString *)titleView:(JXCategoryTitleView *)titleView titleForIndex:(NSInteger)index;
  19. // 如果将JXCategoryTitleView嵌套进UITableView的cell,每次重用的时候,JXCategoryTitleView进行reloadData时,会重新计算所有的title宽度。所以该应用场景,需要UITableView的cellModel缓存titles的文字宽度,再通过该代理方法返回给JXCategoryTitleView。
  20. // 如果实现了该方法就以该方法返回的宽度为准,不触发内部默认的文字宽度计算。
  21. - (CGFloat)categoryTitleView:(JXCategoryTitleView *)titleView widthForTitle:(NSString *)title;
  22. @end
  23. @interface JXCategoryTitleView : JXCategoryIndicatorView
  24. @property (nonatomic, weak) id<JXCategoryTitleViewDataSource> titleDataSource;
  25. @property (nonatomic, strong) NSArray <NSString *>*titles;
  26. @property (nonatomic, assign) NSInteger titleNumberOfLines; //默认:1
  27. @property (nonatomic, strong) UIColor *titleColor; //默认:[UIColor blackColor]
  28. @property (nonatomic, strong) UIColor *titleSelectedColor; //默认:[UIColor redColor]
  29. @property (nonatomic, strong) UIFont *titleFont; //默认:[UIFont systemFontOfSize:15]
  30. @property (nonatomic, strong) UIFont *titleSelectedFont; //文字被选中的字体。默认:与titleFont一样
  31. @property (nonatomic, assign, getter=isTitleColorGradientEnabled) BOOL titleColorGradientEnabled; //默认:NO,title的颜色是否渐变过渡
  32. @property (nonatomic, assign, getter=isTitleLabelMaskEnabled) BOOL titleLabelMaskEnabled; //默认:NO,titleLabel是否遮罩过滤。
  33. //----------------------titleLabelZoomEnabled-----------------------//
  34. @property (nonatomic, assign, getter=isTitleLabelZoomEnabled) BOOL titleLabelZoomEnabled; //默认为NO。为YES时titleSelectedFont失效,以titleFont为准。
  35. @property (nonatomic, assign, getter=isTitleLabelZoomScrollGradientEnabled) BOOL titleLabelZoomScrollGradientEnabled; //手势滚动中,是否需要更新状态。默认为YES
  36. @property (nonatomic, assign) CGFloat titleLabelZoomScale; //默认1.2,titleLabelZoomEnabled为YES才生效。是对字号的缩放,比如titleFont的pointSize为10,放大之后字号就是10*1.2=12。
  37. @property (nonatomic, assign) CGFloat titleLabelZoomSelectedVerticalOffset; //titleLabelZoomEnabled设置为YES,会对titleLabel进行transform缩放,当titleLabelZoomScale过大时(比如设置为2),选中的文本被放大之后底部会有很大的空白,从视觉上看就跟其他未选中的文本不在一个水平线上。这个时候就可以用这个值进行调整。
  38. //----------------------titleLabelStrokeWidth-----------------------//
  39. @property (nonatomic, assign, getter=isTitleLabelStrokeWidthEnabled) BOOL titleLabelStrokeWidthEnabled; //默认:NO
  40. @property (nonatomic, assign) CGFloat titleLabelSelectedStrokeWidth; //默认:-3,用于控制字体的粗细(底层通过NSStrokeWidthAttributeName实现)。使用该属性,务必让titleFont和titleSelectedFont设置为一样的!!!
  41. //----------------------titleLabel缩放中心位置-----------------------//
  42. @property (nonatomic, assign) CGFloat titleLabelVerticalOffset; //titleLabel锚点垂直方向的位置偏移,数值越大越偏离中心,默认为:0
  43. @property (nonatomic, assign) JXCategoryTitleLabelAnchorPointStyle titleLabelAnchorPointStyle; //titleLabel锚点位置,用于调整titleLabel缩放时的基准位置。默认为:JXCategoryTitleLabelAnchorPointStyleCenter
  44. #pragma mark - ************2021.1.15 新增方法,动态刷新cell和指示器状态**************
  45. // 主要用于某些场景下动态改变cell和指示器的颜色
  46. /// 刷新所有cell状态
  47. - (void)gk_refreshCellState;
  48. /// 刷新所有指示器状态
  49. - (void)gk_refreshIndicatorState;
  50. /// 刷新所有cell和指示器状态
  51. - (void)gk_refreshCellAndIndicatorState;
  52. @end