Skip to content

Instantly share code, notes, and snippets.

@bensheldon
Last active May 16, 2020 18:09
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensheldon/5751863 to your computer and use it in GitHub Desktop.
Save bensheldon/5751863 to your computer and use it in GitHub Desktop.
Creating a flat navigation bar in a RubyMotion iOS iPhone app. (screenshot in the comments)
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
# ...
navigation_appearance
#...
end
def navigation_appearance
# Background Color
UINavigationBar.appearance.setBackgroundImage UIImage.alloc.init, # use an empty image
forBarMetrics: UIBarMetricsDefault
UINavigationBar.appearance.setBackgroundColor "#3076B4".to_color
# Remove Shadow
UINavigationBar.appearance.setShadowImage UIImage.alloc.init # use an empty image
UINavigationBar.appearance.setTitleTextAttributes({
UITextAttributeTextColor => UIColor.whiteColor,
UITextAttributeTextShadowColor => UIColor.clearColor,
UITextAttributeTextShadowOffset => NSValue.valueWithUIOffset(UIOffsetMake(0,0)),
UITextAttributeFont => UIFont.fontWithName("Lato-Regular", size: 20)
})
end
end
@bensheldon
Copy link
Author

flat navigation

@sammorrisdesign-zz
Copy link

Thanks for this. How would you allow for translucency behind the bar?

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