diff --git a/BDKCollectionIndexView.h b/BDKCollectionIndexView.h index ec6c6f8..bda8675 100644 --- a/BDKCollectionIndexView.h +++ b/BDKCollectionIndexView.h @@ -39,7 +39,16 @@ typedef NS_ENUM(NSInteger, BDKCollectionIndexViewDirection) { */ @property (readonly) NSString *currentIndexTitle; -@property (strong, nonatomic) UIColor *backgroundColor; +/** + The background color of the "touch status view" that appears when the view is touched. + */ +@property (strong, nonatomic) UIColor *touchStatusBackgroundColor; + +/** + The amount of alpha applied to the "touch status view" that appears when the view is touched. + */ +@property (nonatomic) CGFloat touchStatusViewAlpha; +//@property (strong, nonatomic) UIColor *backgroundColor; /** @@ -71,7 +80,7 @@ typedef NS_ENUM(NSInteger, BDKCollectionIndexViewDirection) { @optional -- (void)collectionIndexView:(BDKCollectionIndexView *)collectionIndexView isPressedOnIndex:(NSUInteger)pressedIndex; +- (void)collectionIndexView:(BDKCollectionIndexView *)collectionIndexView isPressedOnIndex:(NSUInteger)pressedIndex indexTitle:(NSString *)indexTitle; - (void)collectionIndexView:(BDKCollectionIndexView *)collectionIndexView liftedFingerFromIndex:(NSUInteger)pressedIndex; @end diff --git a/BDKCollectionIndexView.m b/BDKCollectionIndexView.m index 62f6c68..d2ed02b 100644 --- a/BDKCollectionIndexView.m +++ b/BDKCollectionIndexView.m @@ -52,8 +52,9 @@ @implementation BDKCollectionIndexView @synthesize delegate = _delegate, currentIndex = _currentIndex, - direction = _direction, - backgroundColor = _backgroundColor; + touchStatusBackgroundColor = _touchStatusBackgroundColor, + touchStatusViewAlpha = _touchStatusViewAlpha, + direction = _direction; + (instancetype)indexViewWithFrame:(CGRect)frame indexTitles:(NSArray *)indexTitles { return [[self alloc] initWithFrame:frame indexTitles:indexTitles]; @@ -70,8 +71,10 @@ - (instancetype)initWithFrame:(CGRect)frame indexTitles:(NSArray *)indexTitles { } _currentIndex = 0; + _touchStatusViewAlpha = 0.25; + _touchStatusBackgroundColor = [UIColor blackColor]; self.tintColor = [UIColor blackColor]; - _backgroundColor = [UIColor clearColor]; + self.backgroundColor = [UIColor clearColor]; SEL handleGestureSelector = @selector(handleGesture:); @@ -244,7 +247,7 @@ - (void)buildIndexLabels { label.tag = tag; tag = tag + 1; label.font = [UIFont boldSystemFontOfSize:12]; - label.backgroundColor = _backgroundColor; + label.backgroundColor = self.backgroundColor; label.textColor = self.tintColor; label.textAlignment = NSTextAlignmentCenter; label.isAccessibilityElement = NO; @@ -282,8 +285,8 @@ - (void)setNewIndexForPoint:(CGPoint)point { } - (void)setBackgroundVisibility:(BOOL)flag { - CGFloat alpha = flag ? 0.25 : 0; - self.touchStatusView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:alpha]; + CGFloat alpha = flag ? self.touchStatusViewAlpha : 0; + self.touchStatusView.backgroundColor = [self.touchStatusBackgroundColor colorWithAlphaComponent:alpha]; } #pragma mark - Gestures @@ -298,8 +301,9 @@ - (void)handleGesture:(UIGestureRecognizer *)recognizer { [self.delegate collectionIndexView:self liftedFingerFromIndex:self.currentIndex]; } } else { - if ([self.delegate respondsToSelector:@selector(collectionIndexView:isPressedOnIndex:)]) { - [self.delegate collectionIndexView:self isPressedOnIndex:self.currentIndex]; + if ([self.delegate respondsToSelector:@selector(collectionIndexView:isPressedOnIndex:indexTitle:)]) { + + [self.delegate collectionIndexView:self isPressedOnIndex:self.currentIndex indexTitle:self.currentIndexTitle]; } }