【发布时间】:2020-05-15 08:29:34
【问题描述】:
我正在尝试构建自己的自定义标签栏视图,但在构建自定义按钮时,我无法更改 Image() 的颜色。
struct TabBarButton: View {
let title: String
let icon: String
var body: some View {
return GeometryReader{ geometry in
VStack {
Image(self.icon)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geometry.size.width/2, height: CGFloat(25))
.foregroundColor(.white)
Text(self.title)
.font(.system(size: 8))
.foregroundColor(Color.white)
}
}
}
}
我尝试过foregroundColor(Color.white)、accentColor(Color.white) 和一些不同的颜色倍增器。除了默认黑色之外,还有什么原因吗?简单的解决方法就是获得白色图标,但希望我现在能解决这个问题。
【问题讨论】:
标签: swiftui