Skip to content

Commit

Permalink
Add horizontal scrollEnabled function.
Browse files Browse the repository at this point in the history
Signed-off-by: RamWire <fy.zhao@renrunkeji.com>
  • Loading branch information
RamWire committed Nov 1, 2016
1 parent 6c59364 commit 1b9256b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion NinaPagerView/NinaBaseView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@property (assign, nonatomic) CGFloat titlesFont; /**< 标题字体大小 **/
@property (assign, nonatomic) CGFloat topHeight; /**< TopTab高度 **/
@property (assign, nonatomic) BOOL topTabUnderLineHidden; /**< 是否显示下方的下划线 **/
@property (assign, nonatomic) BOOL slideEnabled; /**< 允许下方左右滑动 **/
@property (strong, nonatomic) UIColor *btnUnSelectColor; /**< 未选中的标题颜色 **/
@property (strong, nonatomic) UIColor *btnSelectColor; /**< 选中的标题颜色 **/
@property (strong, nonatomic) UIColor *underlineBlockColor; /**< 下划线或滑块颜色 **/
Expand All @@ -54,4 +55,4 @@
*/
- (instancetype)initWithFrame:(CGRect)frame WithTopTabType:(NSInteger)topTabNum;

@end
@end
8 changes: 8 additions & 0 deletions NinaPagerView/NinaBaseView.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ - (void)setTopTabUnderLineHidden:(BOOL)topTabUnderLineHidden {
_topTabUnderLineHidden = topTabUnderLineHidden;
}

- (void)setSlideEnabled:(BOOL)slideEnabled {
_slideEnabled = slideEnabled;
}

- (void)setTopHeight:(CGFloat)topHeight {
_topHeight = topHeight;
}
Expand Down Expand Up @@ -105,6 +109,9 @@ - (UIScrollView *)scrollView {
_scrollView.tag = 318;
_scrollView.backgroundColor = UIColorFromRGB(0xfafafa);
_scrollView.contentSize = CGSizeMake(FUll_VIEW_WIDTH * _titleArray.count, 0);
if (!_slideEnabled) {
_scrollView.scrollEnabled = NO;
}
_scrollView.pagingEnabled = YES;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.alwaysBounceHorizontal = YES;
Expand All @@ -127,6 +134,7 @@ - (UIScrollView *)topTab {
_topTab.scrollEnabled = YES;
_topTab.alwaysBounceHorizontal = YES;
_topTab.showsHorizontalScrollIndicator = NO;
_topTab.showsVerticalScrollIndicator = NO;
_topTab.bounces = NO;
_topTab.scrollsToTop = NO;
CGFloat additionCount = 0;
Expand Down
15 changes: 10 additions & 5 deletions NinaPagerView/NinaPagerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,21 @@ typedef NS_ENUM(NSInteger, NinaPagerStyle) {
**/
@property (assign, nonatomic) BOOL nina_navigationBarHidden;
/**<
* 是否一次性加载全部页面或控制器。
* Load whole viewcontrollers or views.
* 是否一次性加载全部页面或控制器,默认为否
* Load whole viewcontrollers or views,default is NO.
**/
@property (assign, nonatomic) BOOL loadWholePages;
/**<
* 上方TopTab下面的总览线是否隐藏。
* Hide the topTab's underline(not the select underline) or not.
* 上方TopTab下面的总览线是否隐藏,默认为不隐藏
* Hide the topTab's underline(not the select underline) or not,default is NO.
**/
@property (assign, nonatomic) BOOL underLineHidden;
/**<
* 允许下方视图进行左右滑动,默认为允许。
* Able to scroll scrollview in main view,default is YES.
**/
@property (assign, nonatomic) BOOL nina_scrollEnabled;

@property (weak, nonatomic) id<NinaPagerViewDelegate>delegate; /**< NinaPagerView代理 **/

@end
@end
7 changes: 7 additions & 0 deletions NinaPagerView/NinaPagerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@interface NinaPagerView()<NSCacheDelegate>
@property (nonatomic, strong) NSCache *limitControllerCache; /**< 缓存限制 **/
@property (nonatomic, strong) NinaBaseView *ninaBaseView; /**< 创建NinaBaseView **/
@property (nonatomic, assign) BOOL hasSettingScrollEnabled;
@end

@implementation NinaPagerView
Expand Down Expand Up @@ -102,6 +103,11 @@ - (void)setUnderLineHidden:(BOOL)underLineHidden {
_underLineHidden = underLineHidden;
}

- (void)setNina_scrollEnabled:(BOOL)nina_scrollEnabled {
_nina_scrollEnabled = nina_scrollEnabled;
_hasSettingScrollEnabled = YES;
}

- (void)setTopTabHeight:(CGFloat)topTabHeight {
_topTabHeight = topTabHeight;
}
Expand Down Expand Up @@ -154,6 +160,7 @@ - (void)loadDataForView {
self.ninaBaseView.titleScale = _titleScale > 0?_titleScale:1.15;
self.ninaBaseView.titlesFont = _titleFont > 0?_titleFont:14;
self.ninaBaseView.topTabUnderLineHidden = _underLineHidden;
self.ninaBaseView.slideEnabled = _hasSettingScrollEnabled?_nina_scrollEnabled:YES;
self.ninaBaseView.blockHeight = _sliderHeight > 0?_sliderHeight:tabHeight;
self.ninaBaseView.bottomLinePer = _selectBottomLinePer > 0?_selectBottomLinePer:1;
self.ninaBaseView.bottomLineHeight = _selectBottomLineHeight > 0?_selectBottomLineHeight:2;
Expand Down

0 comments on commit 1b9256b

Please sign in to comment.