Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion YSLContainerViewController/YSLContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ @interface YSLContainerViewController () <UIScrollViewDelegate, YSLScrollMenuVie
@end

@implementation YSLContainerViewController
- (id)initWithControllers:(NSArray *)controllers
topBarHeight:(CGFloat)topBarHeight
parentViewController:(UIViewController *)parentViewController selectedIndex:(NSInteger)index{

self = [self initWithControllers:controllers topBarHeight:topBarHeight parentViewController:parentViewController];
self.currentIndex = index;
return self;
}

- (id)initWithControllers:(NSArray *)controllers
topBarHeight:(CGFloat)topBarHeight
parentViewController:(UIViewController *)parentViewController
{
self = [super init];
self.currentIndex = 0;
if (self) {

[parentViewController addChildViewController:self];
Expand Down Expand Up @@ -91,7 +100,7 @@ - (void)viewDidLoad {
[self.view addSubview:_menuView];
[_menuView setShadowView];

[self scrollMenuViewSelectedIndex:0];
[self scrollMenuViewSelectedIndex:_currentIndex];
}

#pragma mark -- private
Expand Down Expand Up @@ -192,4 +201,9 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
[self setChildViewControllerWithCurrentIndex:self.currentIndex];
}


- (void) selectTabByIndex:(NSInteger)index{
[self scrollMenuViewSelectedIndex:index];
}

@end
1 change: 1 addition & 0 deletions YSLContainerViewController/YSLScrollMenuView.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
- (void)setItemTextColor:(UIColor *)itemTextColor
seletedItemTextColor:(UIColor *)selectedItemTextColor
currentIndex:(NSInteger)currentIndex;

@end
2 changes: 1 addition & 1 deletion YSLContainerViewController/YSLScrollMenuView.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ - (void)setIndicatorViewFrameWithRatio:(CGFloat)ratio isNextItem:(BOOL)isNextIte
}

if (indicatorX < kYSLScrollMenuViewMargin || indicatorX > self.scrollView.contentSize.width - (kYSLScrollMenuViewMargin + kYSLScrollMenuViewWidth)) {
return;
// return;
}
_indicatorView.frame = CGRectMake(indicatorX, _scrollView.frame.size.height - kYSLIndicatorHeight, kYSLScrollMenuViewWidth, kYSLIndicatorHeight);
// NSLog(@"retio : %f",_indicatorView.frame.origin.x);
Expand Down