[英]UIView.animate not working in testflight - Xcode 8 Swift 3
[英]Trying change Button Title and label.center.x in UIView.animate when press button but stuck. Why? Swift 4 Xcode 9.4
我的问题
我正在尝试在touchInside button时使用UIView.animate(..)使用标签进行一些动画处理。 一切正常,直到我添加一行:“ self?.confirm.setTitle(”Đăngnhập“,for:.normal)。该动画无法正常工作。
我的意志
我想下面ĐăngKY开关黄色下划线以下Đăng纳米羟基磷灰石 。
当代码是
@IBAction func signUpAction(_ sender:Any?){
if (signup == false){
signup = true
UIView.animate(withDuration: 0.4, delay: 0, options: [.curveEaseIn], animations: {[weak self] in
self?.underlineSignup.center.x -= (self?.underlineSignup.bounds.width)!
self?.view.layoutIfNeeded()
}, completion: nil)
}
}
@IBAction func signInAction(_ sender:Any?){
if (signup == true){
signup = false
UIView.animate(withDuration: 0.4, delay: 0, options: [.curveEaseIn], animations: {[weak self] in
self?.underlineSignup.center.x += (self?.underlineSignup.bounds.width)!
self?.view.layoutIfNeeded()
}, completion: nil)
}
}
但是当我添加.setTitle
@IBAction func signUpAction(_ sender:Any?){
if (signup == false){
signup = true
UIView.animate(withDuration: 0.4, delay: 0, options: [.curveEaseIn], animations: {[weak self] in
self?.underlineSignup.center.x -= (self?.underlineSignup.bounds.width)!
self?.confirm.setTitle("Đăng ký", for: .normal)
self?.view.layoutIfNeeded()
}, completion: nil)
}
}
@IBAction func signInAction(_ sender:Any?){
if (signup == true){
signup = false
UIView.animate(withDuration: 0.4, delay: 0, options: [.curveEaseIn], animations: {[weak self] in
self?.underlineSignup.center.x += (self?.underlineSignup.bounds.width)!
self?.confirm.setTitle("Đăng nhập", for: .normal)
self?.view.layoutIfNeeded()
}, completion: nil)
}
}
请任何人都可以解释这种情况。
编辑:
动画有效,但目的地始终是Đăngký下的第一个位置(动画来自它的左侧或右侧,结果始终是第一位)
我想我知道这是怎么回事。 因为在setTitle中有updateFrame Constraintlayout视图。 我在构建按钮时有一个问题。 当我设置标题时,它将使用约束重置视图。 我就是这么想的。
尝试完成“ setTitle”。
UIView.animate(withDuration: 0.15, delay: 0, options: .curveLinear, animations: {
self?.underlineSignup.center.x -= (self?.underlineSignup.bounds.width)!
self?.view.layoutIfNeeded()
}){
//completion
self?.confirm.setTitle("Đăng ký", for: .normal)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.