JXCategoryTitleView.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // 如果将JXCategoryTitleView嵌套进UITableView的cell,每次重用的时候,JXCategoryTitleView进行reloadData时,会重新计算所有的title宽度。所以该应用场景,需要UITableView的cellModel缓存titles的文字宽度,再通过该代理方法返回给JXCategoryTitleView。
  16. // 如果实现了该方法就以该方法返回的宽度为准,不触发内部默认的文字宽度计算。
  17. - (CGFloat)categoryTitleView:(JXCategoryTitleView *)titleView widthForTitle:(NSString *)title;
  18. @end
  19. @interface JXCategoryTitleView : JXCategoryIndicatorView
  20. @property (nonatomic, weak) id<JXCategoryTitleViewDataSource> titleDataSource;
  21. @property (nonatomic, strong) NSArray <NSString *>*titles;
  22. @property (nonatomic, assign) NSInteger titleNumberOfLines; //默认:1
  23. @property (nonatomic, strong) UIColor *titleColor; //默认:[UIColor blackColor]
  24. @property (nonatomic, strong) UIColor *titleSelectedColor; //默认:[UIColor redColor]
  25. @property (nonatomic, strong) UIFont *titleFont; //默认:[UIFont systemFontOfSize:15]
  26. @property (nonatomic, strong) UIFont *titleSelectedFont; //文字被选中的字体。默认:与titleFont一样
  27. @property (nonatomic, assign, getter=isTitleColorGradientEnabled) BOOL titleColorGradientEnabled; //默认:NO,title的颜色是否渐变过渡
  28. @property (nonatomic, assign, getter=isTitleLabelMaskEnabled) BOOL titleLabelMaskEnabled; //默认:NO,titleLabel是否遮罩过滤。
  29. //----------------------titleLabelZoomEnabled-----------------------//
  30. @property (nonatomic, assign, getter=isTitleLabelZoomEnabled) BOOL titleLabelZoomEnabled; //默认为NO。为YES时titleSelectedFont失效,以titleFont为准。
  31. @property (nonatomic, assign, getter=isTitleLabelZoomScrollGradientEnabled) BOOL titleLabelZoomScrollGradientEnabled; //手势滚动中,是否需要更新状态。默认为YES
  32. @property (nonatomic, assign) CGFloat titleLabelZoomScale; //默认1.2,titleLabelZoomEnabled为YES才生效。是对字号的缩放,比如titleFont的pointSize为10,放大之后字号就是10*1.2=12。
  33. @property (nonatomic, assign) CGFloat titleLabelZoomSelectedVerticalOffset; //titleLabelZoomEnabled设置为YES,会对titleLabel进行transform缩放,当titleLabelZoomScale过大时(比如设置为2),选中的文本被放大之后底部会有很大的空白,从视觉上看就跟其他未选中的文本不在一个水平线上。这个时候就可以用这个值进行调整。
  34. //----------------------titleLabelStrokeWidth-----------------------//
  35. @property (nonatomic, assign, getter=isTitleLabelStrokeWidthEnabled) BOOL titleLabelStrokeWidthEnabled; //默认:NO
  36. @property (nonatomic, assign) CGFloat titleLabelSelectedStrokeWidth; //默认:-3,用于控制字体的粗细(底层通过NSStrokeWidthAttributeName实现)。使用该属性,务必让titleFont和titleSelectedFont设置为一样的!!!
  37. //----------------------titleLabel缩放中心位置-----------------------//
  38. @property (nonatomic, assign) CGFloat titleLabelVerticalOffset; //titleLabel锚点垂直方向的位置偏移,数值越大越偏离中心,默认为:0
  39. @property (nonatomic, assign) JXCategoryTitleLabelAnchorPointStyle titleLabelAnchorPointStyle; //titleLabel锚点位置,用于调整titleLabel缩放时的基准位置。默认为:JXCategoryTitleLabelAnchorPointStyleCenter
  40. @end