In a project created in Titanium Appcelerator/Alloy I created a simple window with a TabGroup button. That button opens a modal window, which contains a NavigationBar.
Without specifying anything in the TSS files, a gray tint is applied to both the TabGroup and the NavigationBar(s). I'd like to remove it and make everything translucent, as it would look natively.
Moreover, you can see that the NavigationBar of the modal window is translucent during the opening animation, and then it suddenly becomes gray after the navigation.
If you want nav buttons in header-bar area, then your only solution is to use these two properties:
1- Window's barColor property
2- Window's translucent property
Using first property, you can set any background color in navigation header area, and setting 2nd one to false - you can remove the transparency which will show the actual color you apply using 1st property.
Moreover, you can use Window's navTintColor to tweaks tint changes in navigation header
+
You can apply font & color using Window's titleAttributes property.
titleAttributes : {
color : 'white',
font : { fontFamily : 'some-family', fontSize : 18 },
},
Here's a sample app I have created which shows demo of manual Modal Window animation for further fully customisation: Sample App for manual Modal Animation
Related
I've implemented the pinned top app bar scroll container, and it works for changing the app bar color on scroll, however the status bar color isn't affected at all.
Here's what I have:
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
Scaffold(
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
// just a wrapper for CenterAlignedTopAppBar
StandardTopAppBar("Home", scrollBehavior = scrollBehavior)
}
){ ... }
If it's relevant, in order to detect if the soft keyboard is present, I enabled:
WindowCompat.setDecorFitsSystemWindows(window, false)
And my status bar color in initially set in my Theme. It was set to primary color when I autogenerated the project in android studios, but I changed it to surface color to match the appbar standards:
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.surface.toArgb()
//(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = !darkTheme // changed from just darkTheme
}
}
tl;dr; top app bar color changes on scroll, but status bar does not. What is the correct pattern to use here? I looked through some of the pinnedScrollBehavior code, and I don't see anything that would invoke status bar changes, so I'm wondering if I'm supposed to have the status bar be transparent and change the insets for the appbar? Or should I manually hook into the scroll logic and change the color myself? Any help is appreciated!
In Theme.kt, inside the YourAppTheme() function add.
WindowCompat.setDecorFitsSystemWindows(window, false)
Doing this will display contents below StatusBar and NavigationBar* (
Only on older versions of Jetpack Compose. In newer versions, PaddingValues are correctly set by default. ).
Now set the StatusBar and NavigationBar color to Color.Transparent.
// make sure to use the compose color package, not the default one
import androidx.compose.ui.graphics.Color
window.statusBarColor = Color.Transparent.toArgb()
window.navigationBarColor = Color.Transparent.toArgb()
You also need to make sure that the padding values for the direct child of Scaffold() are correctly set using the padding values passed in the callback from the Scaffold() composable.
Set the correct StatusBar and NavigationBar icon colors for the theme.
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = !darkTheme
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightNavigationBars = !darkTheme
If you're using ModalBottomSheetLayout or BottomSheetScaffold, you also need to set Insets inside your BottomSheet composable to prevent NavigationBar from overlapping app content using,
Modifier.windowInsetsPadding(WindowInsets.navigationBars)
Edit
In Material3, window.setDecorFitsSystemWindows() is only compatible > API Level 30.
Use WindowCompat.setDecorFitsSystemWindows(window, false) for backwards compatibility.
I'm working on an iOS application that allows a user to change the primary accent color. When the user selects the accent color, all currently displayed elements that contain the accent color need to be updated. I've got a solution that works for everything except the navigation bar's back button text. I can change the title text color and the left carat changes color as expected.
When I use the code below, the left carat immediately changes but the text next to it doesn't.
self.navigationController?.navigationBar.tintColor = accentColor
self.navigationController?.navigationBar.barTintColor = navBarColor
self.navigationController?.navigationBar.titleTextAttributes = [
NSAttributedStringKey.foregroundColor: anotherColor,
NSAttributedStringKey.font: someFont
];
Also, prior to the above code, the UIAppearance proxy for UIBarButtonItem has titleTextAttributes set - but these don't apply to views that are already displayed.
What am I missing here? If the view is dismissed completely and reloaded, the back button text takes on the tintColor. Is there a way to do this without adding a custom backBarButtonItem?
iOS 9+ - swift solution appreciated, but objc is fine, too. This part of the application is storyboard-based.
EDIT: Updated code and description.
UPDATE: The behaviour is different between iOS 11.2 and 10.3. In iOS 11.2, the left and right bar button text color does not update based on the tint for any of the views in the stack until they are reloaded. In iOS 10.3, the colors update but not for the visible view.
My iOS app's color theme is used to set the app's global tint colors. However, in some cases this results in white text on a white background (which I would like to avoid). Is there a way that I could temporarily change my global tint color (or set a specific tint color for that instance)?
The two tint colors in particular that I would like to change within the app are:
UINavigationBar.appearance().tintColor
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).tintColor
Specifically, I would like to change the tint color in a situation where I do not have direct access to the view (such as, when I use UIActivityViewController to share an article and the notes' dialog "cancel" and "save" buttons are white-on-white).
Go through the following link to get a better understanding of tintColor.
https://www.captechconsulting.com/blogs/ios-7-tutorial-series-tint-color-and-easy-app-theming
You can override the global tint colors in a specific view controller for a specific component.
For example if you set the global tint color for UIButton to blueColor, you can do this in your view controller to override the tintColor
myButton.tintColor = UIColor.blueColor()
I'm using Xcode 6.
My app ist by default all white background and black text, text that is present in the title of the nav bar, the table views content, and the tab bar for example.
I would like that all my views (the tab bar and nav bar too) to be dark gray and hence all the text previously mentioned to be white.
Should I set it up for each view of my numerous view controllers, or there is a way to set it up for all the views of the app ?
Thanks for the advice and help
The right way would be to set it up everywhere manually yourself. Because it will be helpful for people in the future to see what you are doing and where.
Another way, which is equally correct would be to create your own customUIViews which would by default channge their colors to grey, and customUITextField which will turn their text white and same goes for labels.
Or use Categories on top of the existing classes of UI, and create a function setUpColor/setupFontColor, and call that function everwhere you want. (I would personally go with the very first solution.)
As shown on Apple's September 2012 keynote, the status bar tint color varies between apps in iOS 6. For instance, Safari and Maps use a black status bar whereas Mail adds a blue tint to it.
Is it possible to set that tint color, or at least force it to black?
You can do it from the plist like Comradsky mention or in xcode 4.5, they added an option for it in the project summary.
Update:
several people were confused by this answer. Just to clarify, you cannot set the status bar tint to any color you want. What is described above is only to change the status bar tint during launch and choose the iOS 6 default status bar color behavior (which picks the color of the bottom row of pixels from your navigation bar).
I've just found how to do it !
In your "Project Summary", in "Status Bar", set "Style" and "Tinting" to "Default.
Then, jump into you xib or storyboard and add a UINavigationBar just below the status bar.
Set the UINavigationBar "Style" to "Default" and select the "Tinting" of your choice.
Run! :-)
If, like me, you don't want any UINavigationBar visible in your Interface, all you want to do is putting the UINavigationBar behind all the Objects, or set the "Alpha" to zero.
You can do that in a tricky way..
In the Project Summary select Status Bar Style Black Transculent from the drop down menu.
In application: didFinishLaunchingWithOptions: enter the following line of code:
self.window.backgroundColor = [UIColor greenColor]; //example color
It works fine for me.
The tint color seems to be determined by the average color of the bottom pixel row of the app's header bar.
See here:
http://www.cultofmac.com/173928/how-ios-6s-cool-new-adaptive-status-bar-works/
It is very easy to do:
just put up an UINavigationBar in your .xib/storyboard, make sure the style is default.
then add a tint. no matter how many views, with different tinted UINavigationBar's, you have your status bar will change its color.
There is no way in iOS 5. You can just change your bar style.
In iOS 6 you can do it in the info.plist:
It is now possible to set status bar tint parameters in your app’s
Info.plist file. You might do this to ensure that the status bar color
matches the navigation bar color of your app during startup. To set
the status bar tint, add the UIStatusBarTintParameters key to your
Info.plist file. The value of this key is a dictionary with the
appropriate values describing the navigation bar your app has at
startup time. Inside the dictionary should be the UINavigationBar key,
whose value is also a dictionary. That dictionary contains the initial
navigation bar’s style (with the Style key) and whether it’s
translucent (with the Translucent key). If your navigation bar uses
them, you can also specify its tint color (with the TintColor key), or
the name of its custom background image (with the BackgroundImage
key).
Check out this link here
Edit:You can also do this in the project summary.