🐍

真ん中にViewを仕込める背景色ありのProgressView

に公開

SwiftUIで「真ん中にViewを仕込めて、背景色ありのProgressView」のサンプルを作ってみました。

こんなやつ

https://github.com/KentaMaeda0916/GaugeProgressViewSample/tree/main

コード

import SwiftUI

struct ContentView: View {
    @State var progressValue = 0.5
    var body: some View {
        VStack {
            GaugeProgressView(
                progressValue: progressValue,
                height: 280,
                lineWidth: 60,
                color: .blue
            ) {
                // 円の中に表示するView
                Text("\(String(format: "%.0f%%", progressValue * 100))") 
                    .font(.largeTitle)
            }
            Button {
                withAnimation {
                    progressValue = progressValue + 0.1
                }
            } label: {
                Text("add progress")
            }
            .padding(80)
            
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

誰かのお役に立てれば幸いです

Discussion