我想在Swift中使用'ShowLess'和'ShowMore'文本创建可扩展标签。如下附图所示。
我试过的代码是
@IBOutlet weak var height: NSLayoutConstraint!
@IBAction func showAction(_ sender: Any) {
UIView.animate(withDuration: 0.3, animations: {
self.state = !self.state
self.height.constant = CGFloat(self.state ? 64: 24)
self.view.layoutIfNeeded()
})
}