我使用的是HMSegmentedcontrol,它有10个段。 默认情况下,视图仅显示3个段,其余部分应滚动。
我的情景:
我的问题:
我的目标:
我如何实现这一目标?
我试过了:
- (void)setIndexChangeBlock:(IndexChangeBlock)indexChangeBlock;
由于我没有将scrollview作为父视图,所以我无法移动该位置。
那么我还能做些什么来实现这个目标呢?
附加代码:
_headerScroll = [[HMSegmentedControl alloc] initWithFrame:CGRectMake(5, 0, commonWidth-10, _tvMovieView.frame.size.height-10)];
[_tvMovieView addSubview:_headerScroll];
_headerScroll.backgroundColor = [UIColor colorWithRed:81.0/255.0f green:80.0f/255.0f blue:82.0f/255.0f alpha:1.0f];
_headerScroll.sectionTitles = titleArray;
_headerScroll.segmentEdgeInset = UIEdgeInsetsMake(0, 7, 0, 7);
_headerScroll.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed;
_headerScroll.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
_headerScroll.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe;
_headerScroll.selectionIndicatorColor = [UIColor whiteColor];
[_headerScroll addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
[_headerScroll setSelectedSegmentIndex:visibleSection animated:YES];
[_headerScroll setTitleFormatter:^NSAttributedString *(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected) {
NSAttributedString *attString;
if (selected) {
attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor],NSFontAttributeName:[COMMON getResizeableFont:OpenSans_SemiBold(11)]}];
return attString;
} else {
attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName : [COMMON Common_Light_BG_Color],NSFontAttributeName:[COMMON getResizeableFont:OpenSans_SemiBold(11)]}];
return attString;
}
}];