Skip to content

Instantly share code, notes, and snippets.

@0oneo
Last active December 25, 2015 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0oneo/a2b3f21e6afb1d57f147 to your computer and use it in GitHub Desktop.
Save 0oneo/a2b3f21e6afb1d57f147 to your computer and use it in GitHub Desktop.
add hairline to a view
//| ----------------------------------------------------------------------------
// Called when the view is about to be displayed. May be called more than
// once.
//
- (void)willMoveToWindow:(UIWindow *)newWindow {
// Use the layer shadow to draw a one pixel hairline under this view.
[self.layer setShadowOffset:CGSizeMake(0, 1.0f/UIScreen.mainScreen.scale)];
[self.layer setShadowRadius:0];
// UINavigationBar's hairline is adaptive, its properties change with
// the contents it overlies. You may need to experiment with these
// values to best match your content.
[self.layer setShadowColor:[UIColor blackColor].CGColor];
[self.layer setShadowOpacity:0.25f];
}
@0oneo
Copy link
Author

0oneo commented Dec 25, 2015

cited from Apple's Demo NavBar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment