gpt4 book ai didi

ios - 以编程方式设置导航栏按钮

转载 作者:行者123 更新时间:2023-11-28 07:09:24 26 4
gpt4 key购买 nike

如何使用 Swift 以编程方式将导航栏按钮设置为特定图像? enter image description here

最佳答案

       let rightButton: UIButton = UIButton.buttonWithType(UIButtonType.Custom) 
rightButton.frame = CGRectMake(0, 0, 40, 40) ;
rightButton.setImage(UIImage(named:"ImageName.png"), forState: UIControlState.Normal)
rightButton.addTarget(self, action: "rightNavButtonClick:", forControlEvents: UIControlEvents.TouchUpInside)

var rightBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: rightButton)

self.navigationItem.setLeftBarButtonItem(rightBarButtonItem, animated: false);

试试这个应该有用!!

关于ios - 以编程方式设置导航栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29070912/

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