|
| 1 | +// |
| 2 | +// BSSegmentView.h |
| 3 | +// BSFrameworks |
| 4 | +// |
| 5 | +// Created by zongheng on 2023/3/21. |
| 6 | +// |
| 7 | + |
| 8 | +#import <UIKit/UIKit.h> |
| 9 | + |
| 10 | +typedef NS_ENUM(NSUInteger, barTitleAligmentType) { |
| 11 | + barTitleAligmentType_Bottom = 0, ///底部对齐 默认 |
| 12 | + barTitleAligmentType_CenterY, ///纵向居中 |
| 13 | + barTitleAligmentType_Top, ///顶部对齐 |
| 14 | +}; |
| 15 | + |
| 16 | +typedef NS_ENUM(NSUInteger, barTitleScrollAligment) { |
| 17 | + barTitleScrollAligment_Normal = 0, ///不处理 |
| 18 | + barTitleScrollAligment_CenterX, ///默认横向居中 |
| 19 | +}; |
| 20 | + |
| 21 | + |
| 22 | +@interface BSSegmentView : UIView |
| 23 | + |
| 24 | +///联动的scrollView,通过监听scrollView的contentoffset变化来处理联动效果 |
| 25 | +@property (nonatomic, weak) UIScrollView *linkScrollView; |
| 26 | +///滚动指示器(底部横条)的宽度比 label 长多少:默认 3 |
| 27 | +@property (nonatomic, assign) CGFloat indicatorGreatLabelWidth; |
| 28 | +///每个标题之间的间距 |
| 29 | +@property (nonatomic, assign) CGFloat lineSpace; |
| 30 | +///默认 1.5 |
| 31 | +@property (nonatomic, assign) CGFloat headIndent; |
| 32 | +///默认 15 |
| 33 | +@property (nonatomic, assign) CGFloat tailIndent; |
| 34 | + |
| 35 | +///设置内容居中展示,适用于个数固定居中展示的样式,如:男生 女生 样式 |
| 36 | +///此种样式 headIndent/tailIndent 无效,contentView的centerX固定为中间, |
| 37 | +///且scrollView不会设置contentSize,即不会滚动 |
| 38 | +@property (nonatomic, assign) BOOL contentViewLayoutCenter; |
| 39 | + |
| 40 | + |
| 41 | +///普通字体和选中后的字体 |
| 42 | +@property (nonatomic, strong) UIFont *normalFont; |
| 43 | +@property (nonatomic, strong) UIFont *selectFont; |
| 44 | + |
| 45 | +///普通字体颜色和选中后的字体颜色 |
| 46 | +@property (nonatomic, strong) UIColor *normalColor; |
| 47 | +@property (nonatomic, strong) UIColor *selectColor; |
| 48 | + |
| 49 | +///标题对齐类型 |
| 50 | +@property (nonatomic, assign) barTitleAligmentType aligmentType; |
| 51 | +//纵向偏移,负数为上偏倚,正数下偏移 |
| 52 | +@property (nonatomic, assign) CGFloat verticalOffsetY; |
| 53 | + |
| 54 | +///选中标题后,标题是否自动滚动到中间 |
| 55 | +@property (nonatomic, assign) barTitleScrollAligment autoScrollType; |
| 56 | +///被选中的item自动滚动后,需要的横向偏移量,负数为向左,正数为向右 |
| 57 | +///只有在 barTitleScrollAligment_CenterX 状态下有用 |
| 58 | +@property (nonatomic, assign) CGFloat horizontalAutoOffsetX; |
| 59 | + |
| 60 | +///默认选中index |
| 61 | +@property (nonatomic, assign) NSUInteger defaultSelectIndex; |
| 62 | + |
| 63 | +///设置标题数据 |
| 64 | +- (void)setDataArr:(NSArray<NSString *> *)dataArr; |
| 65 | + |
| 66 | +///设置选中的标签,只能在 setDataArr 方法之后 |
| 67 | +- (void)setSelectIndex:(NSInteger)selectIndex animate:(BOOL)animate; |
| 68 | + |
| 69 | +///设置底部横线的颜色或图片,如果都设置,以图片优先 |
| 70 | +- (void)setIndicatorLineColor:(UIColor *)lineColor orImage:(UIImage *)image; |
| 71 | + |
| 72 | +@end |
| 73 | + |
| 74 | + |
0 commit comments