Skip to content

Commit c7dc154

Browse files
author
langzhanqiang
committed
2 parents bbb7066 + d0c1e9f commit c7dc154

File tree

159 files changed

+2595
-6978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2595
-6978
lines changed

BSFrameworks.podspec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Pod::Spec.new do |s|
3434
3535
4、轮播图:'2D/3D'(完成)
3636
37+
5、分段控件:segment
38+
3739
3840
DESC
3941

@@ -89,6 +91,11 @@ Pod::Spec.new do |s|
8991
videoloader.source_files = 'BSFrameworks/Classes/BSVideoPreLoader/**/*{.h,.m}'
9092

9193
end
94+
95+
s.subspec 'BSSegmentView' do |segmentView|
96+
segmentView.source_files = 'BSFrameworks/Classes/BSSegment/**/*{.h,.m}'
97+
end
98+
9299
# 上拉下拉刷新控件
93100
# s.subspec 'BSRefresh' do |ss|
94101
# ss.source_files = 'BSFrameworks/Classes/BSRefresh/**/*{.h,.m}'

BSFrameworks/Classes/BSCategory/UIView+BSView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
1111

1212
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
1313
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
14+
#define SCALE_W(x) (SCREEN_WIDTH/375.0 * x)
1415

1516
//是否全面屏包括X XS XSMax XR
1617
#define iPhoneX (SCREEN_HEIGHT==812||SCREEN_HEIGHT==896)

BSFrameworks/Classes/BSLooperView/BSLooper3DFlowLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
1111

1212
typedef enum : NSUInteger {
1313
BSLOOP_STYLE_NORMAL = 0,// 默认 3D轮播
14-
BSLOOP_STYLE_CARD, // 卡片样式
14+
BSLOOP_STYLE_CARD, // 卡片样式(类似于卡包样式的叠加覆盖效果)
1515
} BSLOOP_STYLE;
1616

1717

BSFrameworks/Classes/BSLooperView/BSLooperView.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ typedef NS_OPTIONS(NSInteger, BSLooperPosition){
5656

5757
//只针对scrollDirection = ScrollDirectionHorizontal的
5858
BSLooperPositionLeft = 0, /// 向左
59-
BSLooperPositionRight = 1<<0, /// 向右
59+
BSLooperPositionRight = 1, /// 向右
6060

6161
//只针对scrollDirection = ScrollDirectionVertical的
62-
BSLooperPositionUp = 2<<1, /// 向上
63-
BSLooperPositionDown = 3<<2 /// 向下
62+
BSLooperPositionUp = 2, /// 向上
63+
BSLooperPositionDown = 3 /// 向下
6464
};
6565

6666

@@ -99,7 +99,9 @@ typedef NS_OPTIONS(NSInteger, BSLooperPosition){
9999

100100

101101
/// ====================================
102-
/// 是否自动轮播(只有无限轮播,才可自动轮播)
102+
/// if isInfinite = NO , autoLoop unavailable
103+
/// 如果没有开启无线轮播,此属性将无效
104+
/// 是否自动轮播
103105
/// ====================================
104106
@property (nonatomic ,assign) BOOL autoLoop;
105107

BSFrameworks/Classes/BSLooperView/BSLooperView.m

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ -(void)initSubViews{
9898

9999
#pragma mark - set method or public
100100

101-
-(void)setAutoLoop:(BOOL)autoLoop{
102-
_autoLoop = autoLoop;
103-
104-
if (autoLoop) {
105-
self.isInfinite = YES;
106-
}
107-
}
108-
109101
-(void)setCellName:(NSString *)cellName{
110102
_cellName = cellName;
111103
/// 注册cell
@@ -138,18 +130,22 @@ -(void)setDataArr:(NSArray *)dataArr{
138130
self.flowLayout.maxIndexRow = self.newDataArr.count - 1;
139131
[self.collectionView reloadData];
140132

141-
self.currentPageIndex = dataArr.count;
133+
if (self.isInfinite) {
134+
self.currentPageIndex = dataArr.count;
135+
}else{
136+
self.currentPageIndex = 0;
137+
}
142138

143139
if (self.loopStyle == BSLOOP_STYLE_CARD) {
144140
[self.collectionView setContentOffset:CGPointMake(self.currentPageIndex*self.collectionView.width, 0) animated:NO];
145141
}else{
146142
/// 默认滚动到 第二个数据源的第一个数组
147143
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.currentPageIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
148144
}
149-
}
150-
151-
if (self.autoLoop) {
152-
[self creatTimer];
145+
146+
if (self.autoLoop) {
147+
[self creatTimer];
148+
}
153149
}
154150
}
155151

@@ -474,6 +470,9 @@ -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPat
474470

475471

476472
#pragma mark - scrollView delegate
473+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
474+
475+
}
477476

478477
/// 减速时,重置 UICollectionView 位置(手动滚动)
479478
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
@@ -514,6 +513,12 @@ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{
514513

515514

516515
#pragma mark - init 属性初始化
516+
- (BOOL)autoLoop {
517+
if (self.isInfinite){
518+
return _autoLoop;
519+
}
520+
return NO;
521+
}
517522

518523
-(UICollectionView *)collectionView{
519524
if (!_collectionView) {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

Comments
 (0)