Last active
May 16, 2020 18:09
-
-
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)
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 characters
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 |
Author
bensheldon
commented
Jun 10, 2013
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