在线直播源码,单独修改状态栏颜色
在线直播源码,单独修改状态栏颜色
实现如下:
struct StatusBarColorModifier: ViewModifier {
var color: UIColor
init(color: UIColor) {
self.color = color
let navibarAppearance = UINavigationBarAppearance()
navibarAppearance.configureWithTransparentBackground()
navibarAppearance.backgroundColor = color
UINavigationBar.appearance().standardAppearance = navibarAppearance
UINavigationBar.appearance().compactAppearance = navibarAppearance
UINavigationBar.appearance().scrollEdgeAppearance = navibarAppearance
}
func body(content: Content) -> some View {
ZStack{
content
VStack {
GeometryReader { geometry in
Color(self.color)
.frame(height: geometry.safeAreaInsets.top)
.edgesIgnoringSafeArea(.top)
Spacer()
}
}
}
}
}
extension View {
func statusBarColor(_ color: Color) -> some View {
self.modifier(StatusBarColorModifier(color: UIColor(color)))
}
}
使用方式如下:
VStack {
}
.statusBarColor(.orange)
以上就是 在线直播源码,单独修改状态栏颜色,更多内容欢迎关注之后的文章