微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么使用 animationPropery 的视图在开始时位置错误?

如何解决为什么使用 animationPropery 的视图在开始时位置错误?

我有动画视图,我在 viewDidAppear 中初始化

 self._view.actionView.layoutIfNeeded()
        self._view.actionView.remakeConstaints()
        actionAnimator = UIViewPropertyAnimator(duration: 0.3,curve: .linear,animations: {
            self._view.actionView.audioButton.layer.cornerRadius = 0
            self._view.actionView.bookButton.layer.cornerRadius = 0
            self._view.actionView.layoutIfNeeded()
        })
        actionAnimator.pausesOnCompletion = true
        actionAnimator?.startAnimation()
//        actionAnimator?.fractionComplete = 0
        headerAnimator?.pauseAnimation()

我的观点:

 private func makeBookButton() {
        addSubview(bookButton)
        bookButton.snp.makeConstraints { make in
            make.leading.equalToSuperview().inset(Dimension.sidePadding)
            make.trailing.equalTo(snp.centerX).offset(-8)
            make.top.bottom.equalToSuperview()
        }
    }
    
    private func makeAudioButton() {
        addSubview(audioButton)
        audioButton.snp.makeConstraints { make in
            make.leading.equalTo(snp.centerX).offset(8)
            make.trailing.equalToSuperview().inset(Dimension.sidePadding)
            make.top.bottom.equalToSuperview()
        }
    }

   func remakeConstaints() {
        audioButton.snp.updateConstraints { make in
            make.leading.equalTo(snp.centerX).offset(1)
            make.trailing.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        bookButton.snp.updateConstraints { make in
            make.leading.equalToSuperview()
            make.trailing.equalTo(snp.centerX).offset(-1)
            make.top.bottom.equalToSuperview()
        }
    }

问题是按钮位置错误。它是有错误的约束。如何使用带有约束的 UIAnimatorProperty 对吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。