Skip to content

Commit 50b2be6

Browse files
committed
Handling issues where ContentMode causes compilation errors on macOS
1 parent 27793ad commit 50b2be6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Sources/LottieUI/Model/LUStateData.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ final public class LUStateData: Equatable {
4646
/// An optional completion closure to be called when the animation model has completes loading.
4747
let onDownloaded = PassthroughSubject<Bool, Never>()
4848
/// Sets the layout of the content
49-
let contentMode: UIView.ContentMode
49+
let contentMode: ContentMode
5050

5151
public init() {
5252
self.type = .name("", .main)
5353
self.speed = 1.0
5454
self.loopMode = .loop
5555
self.range = LUProgressRange()
56-
self.contentMode = .scaleAspectFit
56+
self.contentMode = .fit
5757
}
5858

5959

@@ -67,7 +67,12 @@ final public class LUStateData: Equatable {
6767
/// - isControlEnabled: Setting value will stop the current animation. The default value is `false`
6868
/// - contentView: Sets the layout of the content. Defaults to `.scaleAspectFit`
6969
///
70-
public init(type: LULoadType, speed: Double = 1.0, loopMode: LottieLoopMode = .loop, range: LUProgressRange? = nil, isControlEnabled: Bool = false, contentMode: UIView.ContentMode = .scaleAspectFit) {
70+
public init(type: LULoadType,
71+
speed: Double = 1.0,
72+
loopMode: LottieLoopMode = .loop,
73+
range: LUProgressRange? = nil,
74+
isControlEnabled: Bool = false,
75+
contentMode: ContentMode = .fit) {
7176
self.type = type
7277
self.speed = speed
7378
self.loopMode = loopMode

Sources/LottieUI/View/LUView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class LUView: UIView {
143143
private func setupAnimation(_ aniView: LottieAnimationView, state: LUStateData) {
144144
animationView?.removeFromSuperview()
145145
self.animationView = aniView
146-
aniView.contentMode = state.contentMode
146+
aniView.contentMode = state.contentMode == .fit ? UIView.ContentMode.scaleAspectFit : UIView.ContentMode.scaleAspectFill
147147
aniView.loopMode = state.loopMode
148148
aniView.animationSpeed = state.speed
149149
self.addSubview(aniView)
@@ -282,7 +282,7 @@ class LUView: NSView {
282282
private func setupAnimation(_ aniView: LottieAnimationView, state: LUStateData) {
283283
animationView?.removeFromSuperview()
284284
self.animationView = aniView
285-
aniView.contentMode = state.contentMode
285+
aniView.contentMode = state.contentMode == .fit ? LottieContentMode.scaleAspectFit : LottieContentMode.scaleAspectFill
286286
aniView.loopMode = state.loopMode
287287
aniView.animationSpeed = state.speed
288288
self.addSubview(aniView)

0 commit comments

Comments
 (0)