I understand that you can change the color of the status bar with the code below.
override var preferredStatusBarStyle:UIStatusBarStyle{
return UISTatusBarStyle.lightContent
}
However, if I want to change the color when I press UIButton, what should I do?
I want to be able to change it with animation.
swift xcode swift4
You can use this method to reflect style.
setNeedsStatusBarAppearanceUpdate()
Indicators to the system that the view controller status bar attributes have changed.
Call this method if the view controller's status bar attributes, such as hidden/unhidden status or style, change.If you call this method with an animation block, the changes are animated along with the rest of the animation block.
© 2024 OneMinuteCode. All rights reserved.