'Circle in SwiftUI doesn't show in my iPhone
I have two Circle
s to show a circle progress bar, one of these is the progress the another one is the background, but the progress circle doesn't show in my iPhone. This is my code:
struct ProgressBarView: View {
@Environment(\.colorScheme) var colorScheme: ColorScheme
var body: some View {
ZStack {
Group {
Circle()
.stroke(lineWidth: 14.0)
.opacity(colorScheme == .dark ? 1 : 0.3)
Circle()
.trim(from: 0.0, to: 0.3 )
.stroke(style: StrokeStyle(lineWidth: 14.0, lineCap: .round, lineJoin: .round))
.foregroundColor(colorScheme == .dark ? .blue : Color("DarkBlue"))
.rotationEffect(Angle(degrees: 270.0))
Text("16hrs")
.font(.system(size: 22))
.fontWeight(.regular)
}//: Group
.foregroundColor(colorScheme == .dark ? .white : Color("DarkBlue"))
}
}}
Solution 1:[1]
The same error happens... because you're trying to call a color that doesn't exist (I'm guessing). Do note that the Color
declaration requires that you both spell and capitalize correctly. You must either add this color to the Asset Catalog or, as @Yrb stated above,
I had the same symptoms when I pasted the code until I changed Color("DarkBlue") to a standard color.
If you do want a good Dark Blue color, I would suggest hex #00008b
.
Solution 2:[2]
You're looking to add a Color Set to your Assets as it's missing. You can make a custom color using their color panel and set it to whatever you think DarkBlue should be.
Update: I don't see anything wrong with your code, and your Color set in your assets looks fine. Try another Color set and start fresh?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mr Developer |
Solution 2 |