gpt4 book ai didi

ios - 更新 View Controller 中的 UIBarButtonItem

转载 作者:行者123 更新时间:2023-11-29 05:41:04 25 4
gpt4 key购买 nike

我正在尝试从 View Controller 更新 UIBarButtonItem 色调颜色,但没有任何变化。我们不能使用 self.navigationItem.rightBarButtonItem 访问 View Controller 中的 UIBarButtonItem 吗?

[UIView animateWithDuration:.8 delay:0.5 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
//button.alpha = .01; //don't animate alpha to 0, otherwise you won't be able to interact with it
self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
} completion:^(BOOL finished) {
self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
}];

最佳答案

我已经通过制作 UIBarButtonItem 的导出来尝试你的问题。它运行良好。您可以通过直接引用设置色调颜色。

这是代码

class ViewController: UIViewController {

@IBOutlet weak var addItem: UIBarButtonItem!
var username = UITextField()

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.


}

@IBAction func addItem(_ sender: UIBarButtonItem) {

UIView.animate(withDuration: 20) {

self.addItem.tintColor = UIColor.red
}
}
}

关于ios - 更新 View Controller 中的 UIBarButtonItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56542711/

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