Created
May 4, 2015 20:38
Revisions
-
mnem created this gist
May 4, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ #import <UIKit/UIKit.h> @interface NAHMainTable : UITableViewController @end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ #import "NAHMainTable.h" @interface NAHMainTable () @end @implementation NAHMainTable - (void)viewDidLoad { [super viewDidLoad]; [self hairlineNavigationBarLineWithFillColor:[UIColor whiteColor] strokeColor:[UIColor blueColor]]; } - (void)hairlineNavigationBarLineWithFillColor:(UIColor *)fill strokeColor:(UIColor *)stroke { const CGRect slice = CGRectMake(0.0f, 0.0f, 1.0f, 128.0f); // Assuming that all colors are opaque. Paramaterise this if need be. const BOOL opaque = YES; // Create a new context to turn into the background image. UIGraphicsBeginImageContextWithOptions(slice.size, opaque, [UIScreen mainScreen].scale); CGContextRef ctx = UIGraphicsGetCurrentContext(); [fill setFill]; CGContextAddRect(ctx, slice); CGContextFillPath(ctx); [stroke setStroke]; CGContextMoveToPoint(ctx, 0.0f, slice.size.height); CGContextAddLineToPoint(ctx, slice.size.width, slice.size.height); CGContextStrokePath(ctx); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); // Set the background image [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; // Set an empty image for the shadow image, otherwise we'll get a double line [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 0; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return 0; } @end