Skip to content

Commit

Permalink
[#61]feat: 로띠기본설정
Browse files Browse the repository at this point in the history
  • Loading branch information
OLING99 committed Oct 16, 2023
1 parent 7ed20c1 commit 020bbf6
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
4 changes: 4 additions & 0 deletions li/li.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
6FB2E3DA2AB9D9A600884499 /* SF-Pro.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6FB2E3D92AB9D9A600884499 /* SF-Pro.ttf */; };
6FB2E3DC2AB9DB4500884499 /* AppleSDGothicNeo.ttc in Resources */ = {isa = PBXBuildFile; fileRef = 6FB2E3DB2AB9DB4500884499 /* AppleSDGothicNeo.ttc */; };
6FB2E3DE2AB9DBD000884499 /* FontManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2E3DD2AB9DBD000884499 /* FontManager.swift */; };
A924BC0E2ADCEDCD00D9FC62 /* LottieManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A924BC0D2ADCEDCD00D9FC62 /* LottieManager.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -43,6 +44,7 @@
6FB2E3DB2AB9DB4500884499 /* AppleSDGothicNeo.ttc */ = {isa = PBXFileReference; lastKnownFileType = file; path = AppleSDGothicNeo.ttc; sourceTree = "<group>"; };
6FB2E3DD2AB9DBD000884499 /* FontManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontManager.swift; sourceTree = "<group>"; };
6FB2E3E02AB9E97800884499 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
A924BC0D2ADCEDCD00D9FC62 /* LottieManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LottieManager.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -73,6 +75,7 @@
6F1762D82AA48598009D0040 /* LocationManager.swift */,
6F22E7352AAC4E33006A0528 /* HapticManager.swift */,
6FB2E3DD2AB9DBD000884499 /* FontManager.swift */,
A924BC0D2ADCEDCD00D9FC62 /* LottieManager.swift */,
);
path = Manager;
sourceTree = "<group>";
Expand Down Expand Up @@ -222,6 +225,7 @@
6F2501572AA079EA00DA8E8F /* ContentView.swift in Sources */,
6F84329B2AA77115000760AC /* HourlyForcastView.swift in Sources */,
6F1762D92AA48598009D0040 /* LocationManager.swift in Sources */,
A924BC0E2ADCEDCD00D9FC62 /* LottieManager.swift in Sources */,
6F1762DB2AA4F0FD009D0040 /* SevenDayForecastView.swift in Sources */,
6F1762D42AA47D00009D0040 /* MainView.swift in Sources */,
6F2501552AA079EA00DA8E8F /* liApp.swift in Sources */,
Expand Down
96 changes: 96 additions & 0 deletions li/li/Manager/LottieManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// LottieManager.swift
// li
//
// Created by OLING on 2023/10/16.

import Foundation
import Lottie
import SwiftUI
import UIKit

struct Lottiefile : UIViewRepresentable {
typealias UIViewType = UIView

var filename: String
var loopState: Bool
var playState: Bool

func makeUIView(context: UIViewRepresentableContext<Lottiefile>) -> UIView {
let view = UIView(frame: .zero)
//4. Add animation
let animationView = LottieAnimationView()
//사용자 애니메이션 파일명
animationView.animation = LottieAnimation.named(filename)
//애니메이션 크기가 적절하게 조정될 수 있도록
animationView.contentMode = .left
if loopState {
animationView.loopMode = .loop
}
//애니메이션 재생
animationView.play()

//컨테이너의 너비와 높이를 자동으로 지정할 수 있도록
animationView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animationView)

//5. 자동완성 기능
NSLayoutConstraint.activate([
//레이아웃의 높이와 넓이의 제약
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])

return view
}

func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<Lottiefile>) {

}
}

struct LottiePlayState : UIViewRepresentable {

func makeUIView(context: Context) -> Lottie.LottieAnimationView {
let view = UIView(frame: .zero)
//4. Add animation
let animationView = LottieAnimationView()
//사용자 애니메이션 파일명
animationView.animation = LottieAnimation.named(filename)
//애니메이션 크기가 적절하게 조정될 수 있도록
animationView.contentMode = .left

if loopState {
animationView.loopMode = .loop
}


//컨테이너의 너비와 높이를 자동으로 지정할 수 있도록
animationView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animationView)

//5. 자동완성 기능
NSLayoutConstraint.activate([
//레이아웃의 높이와 넓이의 제약
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])

return animationView
}

func updateUIView(_ uiView: Lottie.LottieAnimationView, context: Context) {
if playState {
uiView.play()
}
}


var filename: String
var loopState: Bool
var playState: Bool
}




0 comments on commit 020bbf6

Please sign in to comment.