A Navigation Bar scroller like on the Amazon Kindle iOS application.
##How to use:
-
Deployment target should be 5.0 or later
-
Download ScrollingNavigationDemo
-
Copy ScrollingNavigationViewController.h and ScrollingNavigationViewController.m (It incorporates ARC)
-
Copy Logging.h (since LogTrace has been used in this framework)
-
Subclass ScrollingNavigationViewController and implement ScrollingNavigationDelegate.
@interface ViewController : ScrollingNavigationViewController<ScrollingNavigationDelegate>
-
Call setLabelFont to set the font of labels at navigation bar.
[self setLabelFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:18.0f]];
-
Call setNavigationImage to set an image at navigation bar.
[self setNavigationImage:[UIImage imageNamed:@"nav-bar.png"]];
-
Call setSelectedLabelColor to set the color of selected label.
[self setSelectedLabelColor:[UIColor whiteColor]];
-
Call setUnselectedLabelColor to set the color of unselected label.
[self setUnselectedLabelColor:[UIColor lightTextColor]];
-
Set delegate to self.
self.delegate = self;
-
Intialize navigationTitles (property of ScrollingNavigationViewController of type NSMutableArray) to set the titles at navigation bar.
self.navigationTitles = [[NSMutableArray alloc] initWithObjects:@"Home",@"Personal",@"Office", @"one more", nil];
-
Implement delegate method labelSwitchedAtIndex to know the highlighted option and take appropriate action in your View Controller.This method receives the current index value of the highlighted option.
-(void)labelSwitchedAtIndex:(NSUInteger)index{ _selectedLabel.text = [self.navigationTitles objectAtIndex:self.selectedLabelIndex]; }
#####Steps 6,7,8,9 are optional. ##License SliderSwitch is licensed under the terms of the MIT License. Please see the License file for full details.