2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SwiftUI】シンプルなカスタムローディングを作成する

Posted at

はじめに

最近SwiftUIでのアニメーションの勉強してるので簡単なローディング画面を作ってみました。

こんな感じ

Simulator Screen Recording - iPhone 14 Pro - 2023-09-01 at 22.14.54.gif

実装

import SwiftUI

struct ContentView: View {
    @State private var isLoading = false

    var body: some View {
        Circle()
            .trim(from: 0, to: 0.7)
            .stroke(.black, lineWidth: 5)
            .frame(width: 30, height: 30)
            .rotationEffect(.degrees(isLoading ? 360 : 0))
            .animation(.linear(duration: 1).repeatForever(autoreverses: false), value: isLoading)
            .onAppear {
                isLoading = true
            }
    }
}

おわり

いい感じですね

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?