Allow to specify bar line height. Hide it by default.

This commit is contained in:
Sergey Demchenko 2015-08-08 14:09:35 -07:00
parent c81ef13705
commit d671b801c3
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -31,6 +31,7 @@
@interface XLButtonBarView : UICollectionView
@property (readonly, nonatomic) UIView * selectedBar;
@property (nonatomic) CGFloat selectedBarHeight;
@property UIFont * labelFont;
@property NSUInteger leftRightMargin;

View File

@ -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