LoginSignup
0
0

More than 3 years have passed since last update.

Lottie-iosの基本的な実装の仕方の備忘録[Xcode/Storyboard]

Posted at

ライブラリを使ってLottieを簡単に実装してみたのでアウトプットしようと思います

環境

・Mac Book Pro(macOS:BigSur)
・Xcode(ver:12.5)

実装例

Unknown.gif

LottieのJSONをとってくるサイト

コード例

ViewController.swift
  import UIKit
import Lottie

class ViewController: UIViewController {


    @IBOutlet weak var backView: UIView!
    @IBOutlet weak var animationView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let aniView = AnimationView()
        let animation = Animation.named("2") 
        aniView.frame = animationView.bounds
        aniView.animation = animation
        aniView.contentMode = .scaleAspectFit
        aniView.loopMode = .loop "ループさせる"
        aniView.play()
        animationView.addSubview(aniView) "Viewに追加"

        backView.layer.backgroundColor = UIColor.darkGray.cgColor
        backView.alpha = 0.45
    }
}
0
0
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
0
0