Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

SwiftUIで作りながら学ぶアニメーション 
インジケーター編

SwiftUIで作りながら学ぶアニメーション 
インジケーター編

SwiftUIで作りながら学ぶアニメーション 
インジケーター編
Qiitaに詳しい記事あげます。

Ryo Tsuzukihashi

February 12, 2020
Tweet

More Decks by Ryo Tsuzukihashi

Other Decks in Programming

Transcript

  1. ࡞Ζ͏ struct ContentView: View { var body: some View {

    Circle() .trim(from: 0, to: 0.6) .stroke(Color.green, lineWidth: 8) .frame(width: 48, height: 48) } }
  2. ʁ

  3. rotationEffect(_:anchor:) func rotationEffect( _ angle: Angle, anchor: UnitPoint = .center)

    -> some View Circle() . . . .rotationEffect( Angle(degrees: self.isAnimation ? 360 : 0) ) @State var isAnimation = false
  4. .onAppear() { withAnimation( Animation .linear(duration: 1) .repeatForever(autoreverses: false)) { self.isAnimation.toggle()

    } } @available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) public func withAnimation<Result>( _ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result XJUI"OJNBUJPO @@
  5. Circle() .trim(from: 0, to: 0.6) .stroke( AngularGradient( gradient: Gradient(colors: [.gray,

    .white]), center: .center), style: StrokeStyle( lineWidth: 8, lineCap: .round, dash: [0.1, 16], dashPhase: 8)) .frame(width: 48, height: 48) .rotationEffect( Angle(degrees: self.isAnimation ? 360 : 0)) .onAppear() { withAnimation( Animation .linear(duration: 1) .repeatForever(autoreverses: false)) { self.isAnimation.toggle() } }