Created
October 15, 2015 17:38
-
-
Save semireg/f8168fe7b336723fd406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(instancetype)initWithCoder:(NSCoder *)aDecoder | |
{ | |
self = [super initWithCoder:aDecoder]; | |
if (!self) return nil; | |
[self setupWithIndexTitles:nil]; | |
return self; | |
} | |
- (instancetype)initWithFrame:(CGRect)frame indexTitles:(NSArray *)indexTitles { | |
self = [super initWithFrame:frame]; | |
if (!self) return nil; | |
if (CGRectGetWidth(frame) > CGRectGetHeight(frame)) { | |
_direction = BDKCollectionIndexViewDirectionHorizontal; | |
} else { | |
_direction = BDKCollectionIndexViewDirectionVertical; | |
} | |
[self setupWithIndexTitles:indexTitles]; | |
return self; | |
} | |
-(void)setupWithIndexTitles:(NSArray *)indexTitles { | |
_currentIndex = 0; | |
_touchStatusViewAlpha = 0.25; | |
_touchStatusBackgroundColor = [UIColor blackColor]; | |
self.tintColor = [UIColor blackColor]; | |
self.backgroundColor = [UIColor clearColor]; | |
SEL handleGestureSelector = @selector(handleGesture:); | |
_panner = [[UIPanGestureRecognizer alloc] initWithTarget:self action:handleGestureSelector]; | |
_panner.delegate = self; | |
[self addGestureRecognizer:_panner]; | |
_tapper = [[UITapGestureRecognizer alloc] initWithTarget:self action:handleGestureSelector]; | |
[self addGestureRecognizer:_tapper]; | |
_longPresser = [[UILongPressGestureRecognizer alloc] initWithTarget:self | |
action:handleGestureSelector]; | |
_longPresser.delegate = self; | |
_longPresser.minimumPressDuration = 0.01f; | |
[self addGestureRecognizer:_longPresser]; | |
[self addSubview:self.touchStatusView]; | |
self.indexTitles = indexTitles; | |
self.isAccessibilityElement = YES; | |
self.accessibilityTraits = UIAccessibilityTraitAdjustable; | |
self.accessibilityLabel = NSLocalizedString(@"table index", @"title given to the section index control"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment