gpt4 book ai didi

ios - 如何在iOS swift中隐藏/查看标题 View 表

转载 作者:行者123 更新时间:2023-12-01 18:03:35 24 4
gpt4 key购买 nike

我有静态 UItableview 来保存用户表单。我在表格中添加了标题 View 以显示电子邮件验证文件我的问题是标题没有显示隐藏/显示和与第一行重叠之间的平滑过渡
enter image description here

我想问一下如何修复表格标题 View 的高度并且不使其重叠
代码

@IBOutlet weak var errorView: UIView!

@IBAction func next(_ sender: Any) {
let newUserEmail = self.txtfEmail.text
if isValidEmail(newUserEmail!) {
performSegue(withIdentifier: "addInventryToNewUser", sender: self)
}
else {
cellemail.layer.borderWidth = 2.0
cellemail.layer.borderColor = UIColor.red.cgColor

let f = errorView.frame;
errorView.frame = CGRect(x: f.origin.x, y: f.origin.y, width: f.width, height: 21);
errorView.isHidden = false

lblError.text = "❌ Invalid email address."
}

}

最佳答案

您需要应用一些动画来实现平滑过渡。就是这样:

@IBAction func next(_ sender: Any) {
let newUserEmail = self.txtfEmail.text
if isValidEmail(newUserEmail!) {
performSegue(withIdentifier: "addInventryToNewUser", sender: self)
}
else {
cellemail.layer.borderWidth = 2.0
cellemail.layer.borderColor = UIColor.red.cgColor

UIView.animate(withDuration: 0.5) {
self.errorView.frame.size.height = 21
}
errorView.isHidden = false

lblError.text = "❌ Invalid email address."
}
}

关于ios - 如何在iOS swift中隐藏/查看标题 View 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62222042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com