使用Swift中的UIButton单击此或那个
我使用单个按钮来显示登录字段。如果我们单击一次,登录视图将向左移动,注册视图将显示,然后,如果我们再次单击,注册视图将向右移动,登录视图将显示。我的代码如下。但动画不起作用。请引导我使用Swift中的UIButton单击此或那个,swift,uibutton,Swift,Uibutton,我使用单个按钮来显示登录字段。如果我们单击一次,登录视图将向左移动,注册视图将显示,然后,如果我们再次单击,注册视图将向右移动,登录视图将显示。我的代码如下。但动画不起作用。请引导我 var bottom_click : Bool = true @IBAction func not_member_button(sender: UIButton) { if(bottom_click == false) { UIView.animateWithDuration(0.7,
var bottom_click : Bool = true
@IBAction func not_member_button(sender: UIButton) {
if(bottom_click == false) {
UIView.animateWithDuration(0.7, delay: 0.0, options: .CurveEaseOut, animations: {
self.login_view.frame = CGRectMake(16, 150, 288, 187)
self.crea_acc_view.frame = CGRectMake(370, 150, 288, 245)
}, completion: { finished in
//println("Basket doors opened!")
})
sender.titleLabel?.text = "Not a member? Sign Up" //Its not working. If we delete this, animation is working
bottom_click = true
}
else {
UIView.animateWithDuration(0.7, delay: 0.0, options: .CurveEaseOut, animations: {
self.login_view.frame = CGRectMake(-500, 150, 288, 187)
self.crea_acc_view.frame = CGRectMake(16, 150, 288, 245)
}, completion: { finished in
//println("Basket doors opened!")
})
sender.titleLabel?.text = "Already member? Login" // Its is not working. If we delete this, animation is working
bottom_click = false
}
}
什么不起作用?正在发生的动画有什么问题吗?嗨。。我又编辑了一遍。动画也不起作用,然后是Sender.titleLabel?.text也不起作用?请添加关于什么不起作用的详细信息,函数被调用但条件不满足,或者函数根本不被调用?是否使用自动布局?然后读这个。嗨。。!函数被调用。情况很好。动画不起作用。