Allow to specify bar line height. Hide it by default.
This commit is contained in:
parent
c81ef13705
commit
d671b801c3
|
|
@ -82,7 +82,7 @@
|
|||
[super viewWillAppear:animated];
|
||||
UICollectionViewLayoutAttributes *attributes = [self.buttonBarView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:self.currentIndex inSection:0]];
|
||||
CGRect cellRect = attributes.frame;
|
||||
[self.buttonBarView.selectedBar setFrame:CGRectMake(cellRect.origin.x, self.buttonBarView.frame.size.height - 5, cellRect.size.width, 5)];
|
||||
[self.buttonBarView.selectedBar setFrame:CGRectMake(cellRect.origin.x, self.buttonBarView.frame.size.height - self.buttonBarView.selectedBarHeight, cellRect.size.width, self.buttonBarView.selectedBarHeight)];
|
||||
}
|
||||
|
||||
-(void)reloadPagerTabStripView
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
@interface XLButtonBarView : UICollectionView
|
||||
|
||||
@property (readonly, nonatomic) UIView * selectedBar;
|
||||
@property (nonatomic) CGFloat selectedBarHeight;
|
||||
@property UIFont * labelFont;
|
||||
@property NSUInteger leftRightMargin;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
-(void)initializeXLButtonBarView
|
||||
{
|
||||
_selectedOptionIndex = 0;
|
||||
_selectedBarHeight = 5;
|
||||
if ([self.selectedBar superview] == nil){
|
||||
[self addSubview:self.selectedBar];
|
||||
}
|
||||
|
|
@ -157,14 +158,19 @@
|
|||
|
||||
#pragma mark - Properties
|
||||
|
||||
-(void)setSelectedBarHeight:(CGFloat)selectedBarHeight
|
||||
{
|
||||
_selectedBarHeight = selectedBarHeight;
|
||||
_selectedBar.frame = CGRectMake(_selectedBar.frame.origin.x, self.frame.size.height - _selectedBarHeight, _selectedBar.frame.size.width, _selectedBarHeight);
|
||||
}
|
||||
|
||||
-(UIView *)selectedBar
|
||||
{
|
||||
if (_selectedBar) return _selectedBar;
|
||||
_selectedBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 5, self.frame.size.width, 5)];
|
||||
_selectedBar = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - _selectedBarHeight, 0, _selectedBarHeight)];
|
||||
_selectedBar.layer.zPosition = 9999;
|
||||
_selectedBar.backgroundColor = [UIColor blackColor];
|
||||
return _selectedBar;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in New Issue