我有UIImageView
带有月亮图像。
而moonImageContainerView
是superView
的{{1}}
然后向UIImageView
添加了滑动手势。
如果向上滑动,
moonImageContainerView
您可以使用gif查看结果
https://imgur.com/a/ftShkpO
现在,如果我只添加self.titleLabel.isHidden = false
UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseIn, animations: {
self.moonImageContainerView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
self.moonImageContainerView.center.y = self.view.center.y
}, completion: nil)
我的动画是休息。
self.titleLabel.text = "MY TOPIA"
您可以使用gif查看结果
https://imgur.com/a/y57fPlA
为什么self.titleLabel.text = "MY TOPIA" // Just added this line.
self.titleLabel.isHidden = false
UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseIn, animations: {
self.moonImageContainerView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
self.moonImageContainerView.center.y = self.view.center.y
}, completion: nil)
消失在底部?
我该如何解决?
答案 0 :(得分:0)
好吧,我使用了其余设置,但没有看到您的情况。
import UIKit
class ImageViewController: UIViewController {
@IBOutlet var moonImageContainerView: UIView!
@IBOutlet var titleLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let pan = UISwipeGestureRecognizer.init(target: self, action: #selector(pp(_:)))
pan.direction = .up
moonImageContainerView.addGestureRecognizer(pan)
}
@objc func pp(_ pan: UISwipeGestureRecognizer){
self.titleLabel.text = "MY TOPIA"
self.titleLabel.isHidden = false
UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseIn, animations: {
self.moonImageContainerView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
self.moonImageContainerView.center.y = self.view.center.y
}, completion: nil)
}
}