我的名字是Lennart,我目前正在为WWDC的Playground工作。但不幸的是,我对标签动画有问题。由于某种原因,标签甚至不会对动画作出反应,即使所有其他标签都有,并且它总是以一种特定的方式动画(从右上角移动到中间)。这是我的代码:
startinglbl.text = "Tell us who you are"
startinglbl.numberOfLines = 2
startinglbl.lineBreakMode = .byWordWrapping
startinglbl.frame = CGRect(x: 62, y: 62 + 10, width: 250, height: 100)
startinglbl.font = UIFont(name: "HelveticaNeue-Bold", size: 40)
startinglbl.textColor = UIColor.white
startinglbl.textAlignment = .center
startinglbl.alpha = 0
我在其中添加了一些值并且是我的动画:
func startingAnimation() {
UIView.animate(withDuration: 1, animations: {
self.startinglbl.frame = CGRect(x: 62, y: 62, width: 250, height: 100)
self.startinglbl.alpha = 1
}) { (true) in
UIView.animate(withDuration: 1, animations: {
self.fntextfield.frame = CGRect(x: 87, y: 250, width: 200, height: 30)
self.fntextfield.alpha = 1
}, completion: { (true) in
UIView.animate(withDuration: 1, animations: {
self.lntextfield.frame = CGRect(x: 87, y: 300, width: 200, height: 30)
self.lntextfield.alpha = 1
}, completion: { (true) in
UIView.animate(withDuration: 1, animations: {
self.startingbtn.frame = CGRect(x: 137, y: 450, width: 100, height: 50)
self.startingbtn.alpha = 1
})
})
})
}
}
我真的很感谢你的帮助 非常感谢你
答案 0 :(得分:0)
请记住,如果您使用的是自动布局。然后基于帧的动画不起作用。像这样:
CATransition* transition = [CATransition animation];
transition.duration = 0.4;
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
[_eraserSliderContainer.layer addAnimation:transition
forKey:kCATransition];