I'm trying to add 5 animation views into UIStackView, but I have layout issues: "Width and horizontal position are ambiguous for AnimationView". So my stackView doesn't work correct. Here is the function where I create animation view (I've also tried to set animation view's frame manually - nothing happens):
extension AnimationView {
public func configureCustomAnimationView(with animation: Animation?, speed: CGFloat) -> AnimationView {
let animationView = AnimationView()
animationView.animation = animation
animationView.animationSpeed = speed
animationView.translatesAutoresizingMaskIntoConstraints = false
return animationView
}
}
In my viewController I create 5 properties of Animation views:
private var starOneAnimation = AnimationView().configureCustomAnimationView(with: Animation.starsAnimation, speed: 1)
private var starTwoAnimation = AnimationView().configureCustomAnimationView(with: Animation.starsAnimation, speed: 1)
private var starThreeAnimation = AnimationView().configureCustomAnimationView(with: Animation.starsAnimation, speed: 1)
private var starFourAnimation = AnimationView().configureCustomAnimationView(with: Animation.starsAnimation, speed: 1)
private var starFiveAnimation = AnimationView().configureCustomAnimationView(with: Animation.starsAnimation, speed: 1)
My stackView:
private var starsStack: UIStackView = {
let starsStack = UIStackView()
starsStack.alignment = .center
starsStack.axis = .horizontal
starsStack.distribution = .equalCentering
starsStack.translatesAutoresizingMaskIntoConstraints = false
return starsStack
}()
public override func viewDidLoad() {
super.viewDidLoad()
starsStack.addArrangedSubview(starOneAnimation)
starsStack.addArrangedSubview(starTwoAnimation)
starsStack.addArrangedSubview(starThreeAnimation)
starsStack.addArrangedSubview(starFourAnimation)
starsStack.addArrangedSubview(starFiveAnimation)
}