我想做的是:
当用户点击"忘记密码"标签: 1- UIButton标题更改为"发送"
隐藏2-密码文本字段
3 - 取消标签未隐藏
当用户点击取消时: 显示1-密码文本字段
2- UIButton标题是"登录"
3-舞蹈是隐藏的
@IBAction func forgotTapped(_ sender: UITapGestureRecognizer) {
if passwordtxt.isHidden == false {
loginbtn.titleLabel?.text = "send"
passwordtxt.isHidden = true
forgotLab.isHidden = true
top.constant = -50
cancelLb.isHidden = false
} else {
if passwordtxt.isHidden == true {
forgotLab.isHidden = false
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
loginbtn.titleLabel?.text = "login"
cancelLb.isHidden = true
}
}
}
}
@IBAction func cancelTapped(_ sender: Any) {
cancelLb.isHidden = true
forgotLab.isHidden = false
loginbtn.titleLabel?.text = "send"
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
top.constant = 50
}
}
问题:
现在一切都很好但是当我点击按钮时它会发送"发送"它改为"登录" !!它会回到它的黑色默认标题
无论如何都要让UIButton留下来"发送"即使点击它之后呢?
更新
if passwordtxt.isHidden == false {
loginbtn.setTitle("send", for: .normal)
passwordtxt.isHidden = true
forgotLab.isHidden = true
top.constant = -50
cancelLb.isHidden = false
} else {
if passwordtxt.isHidden == true {
forgotLab.isHidden = false
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
loginbtn.setTitle("login", for: .normal)
cancelLb.isHidden = true
}
}
}
}
@IBAction func cancelTapped(_ sender: Any) {
cancelLb.isHidden = true
forgotLab.isHidden = false
loginbtn.setTitle("send", for: .normal)
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
top.constant = 50
}
}
答案 0 :(得分:0)
@IBAction func forgotTapped(_ sender: UITapGestureRecognizer) {
if passwordtxt.isHidden == false {
passwordtxt.isHidden = true
loginbtn.setTitle("send", for: .normal)
forgotLab.isHidden = true
top.constant = -50
cancelLb.isHidden = false
} else {
if passwordtxt.isHidden == true {
forgotLab.isHidden = false
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
cancelLb.isHidden = true
}
}
}
}
@IBAction func cancelTapped(_ sender: Any) {
loginbtn.setTitle("login", for: .normal)
cancelLb.isHidden = true
forgotLab.isHidden = false
if passwordtxt.isHidden == true {
passwordtxt.isHidden = false
top.constant = 50
}
}