Set the status bar to black colour
For Xcode 8 / iOS 10 / Swift 3:
Change the status bar background color temporarily on one view by adding a colored UIView under the status bar. I put these lines in viewWillAppear()
. my tint is white with 45% transparency, but you can put in any opaque or transparent UIColor value.
let statusView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 20))
statusView.backgroundColor = UIColor.white.withAlphaComponent(0.45)
self.view.addSubview(statusView)
You can add your statusView to the navigationController, instead of the view, if you have a navigation controller on the view.
You can also pass in UIScreen.main.bounds.size.width for the width of the simulated status bar background view. Do not hardcode a width, otherwise it wont fit all devices properly.
Alternatively, you can also change the status bar background throughout your app using this code. be aware that if even if placed in viewWillAppear()
, not viewDidLoad()
, other views will still adopt the altered status bar when you navigate forward/back.
let statWindow = UIApplication.shared.value(forKey:"statusBarWindow") as! UIView
let statusBar = statWindow.subviews[0] as UIView
statusBar.backgroundColor = UIColor.white.withAlphaComponent(0.45)
How to change status bar color in Flutter?
Works totally fine in my app
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.white);
return MaterialApp(
title: app_title,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(title: home_title),
);
}
}
(this package)
UPD:
Recommended solution (Flutter 2.0 and above)
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
How to change the status bar color in Android?
Update:
Lollipop:
public abstract void setStatusBarColor (int color)
Added in API level 21
Android Lollipop brought with it the ability to change the color of status bar in your app for a more immersive user experience and in tune with Google’s Material Design Guidelines
.
Here is how you can change the color of the status bar using the new window.setStatusBarColor
method introduced in API level 21
.
Changing the color of status bar also requires setting two additional flags on the Window; you need to add the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
flag and clear the FLAG_TRANSLUCENT_STATUS
flag.
Working Code:
import android.view.Window;
...
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));
Offcial developer reference : setStatusBarColor(int)
Example :material-design-everywhere
Chris Banes Blog- appcompat v21: material design for pre-Lollipop devices!
The transitionName
for the view background will be android:status:background
.
how to change statusbar color in jetpack compose?
Google has just created a library called accompanist
.
You can find it here: https://github.com/google/accompanist
It contains multiple helpful libraries for Jetpack Compose, among which is a System UI Controller that you can use for changing the status bar color.
Docs - https://google.github.io/accompanist/systemuicontroller/
How to set status bar icon color in Flutter?
Colour of status-bar icon is depend on color of appbar. You can try edit systemOverlayStyle
of AppBar on Home Screen ?
https://api.flutter.dev/flutter/material/AppBar/systemOverlayStyle.html
Is it possible to change status bar icon color to white? Or is there a dark theme status bar? (Kotlin)
In your theme, set windowLightStatusBar
to false -- and you can also set your status bar color in the theme:
<item name="android:statusBarColor">@color/black</item>
<item name="android:windowLightStatusBar">false</item>
Related Topics
Nsurlcache Does Not Clear Stored Responses in iOS8
Binding Viewmodel and Textfields with Swiftui
Why Is -Force_Load No Longer Required for My Three20 Dependencies in Xcode 4.2
The Proper Way of Doing Chain Animations
Disable Autorotate on a Single Subview in iOS8
Add Button at the End of Collection View in Storyboard
Having Uiview Drawrect Occur in a Background Thread
How to Resolve iOS Link Errors with Opencv
iOS Appextension:How to Combine Nsextensionactivationrule and Nspredicate
Apple Watchkit Simulator Issue: Sperrorinvalidbundlenogizmobinarymessage
How to Set the Accessibility Label for a Particular Segment of a Uisegmentedcontrol
Fit Image of Random Size into a Uiwebview (Ios)
Refresh Only the Custom Header Views in a Uitableview
How to Change Uibutton Image After Clicking in Swift
Duplicate Interface Definition for Class 'Gtmhttpuploadfetcher'
Why Don't My Views Show Up in Storyboards and Are Greyed Out in the Left Pane