ios - 标签隐藏很慢
问题描述
代码创建标签和隐藏标签的按钮。但是当运行代码并按下按钮隐藏标签时,隐藏需要很长时间。请帮助我,如何解决这个问题?
import UIKit
class ViewController: UIViewController {
@IBOutlet var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label = UILabel(frame: CGRect(x: 30, y: 30, width: 300, height: 30))
label.text = "Hey"
label.textColor = UIColor.black
self.view.addSubview(label)
let switchButton = UIButton(frame: CGRect(x: 40, y: 500, width: 300, height: 40))
switchButton.setTitle("Change label text", for: .normal)
switchButton.setTitleColor(UIColor.black, for: .normal)
switchButton.backgroundColor = UIColor.gray
switchButton.addTarget(self, action: #selector(hide), for: .touchUpInside)
self.view.addSubview(switchButton)
}
@IBAction func hide(_ sender: Any){
self.label.isHidden = true
print("check")
}
}
UI更新慢
解决方案
推荐阅读
- spring - spring boot一次将多个数据插入表中?
- python - pandas dataframe drop问题,要删除特定行吗?
- typescript - 如何通过 AWS Eventbridge 保存相关 ID
- php - 按钮软删除不起作用laravel 8
- reactjs - 如何通过 jest.mock 在反应中模拟一个类组件?
- excel - 从 excel 列表中获取电子邮件,然后编辑主题并将更新的邮件项目保存为 pdf
- javascript - 为什么我的 Accordion 关闭动画没有触发?它打开(有动画)但没有动画关闭
- node.js - REST API - 排除/包括软删除的项目
- sql - 日期格式:获取月份的最后一天和第一天-sql-DB2
- javascript - process.on('uncaughtException') 没有捕获 ECONNRESET