skip to Main Content

I have two Circles 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"))

        }
}}

assets

2

Answers


  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.

    Login or Signup to reply.
  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?

    colorset

    example

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search