如何设置 UIBarButtonItem alpha
How to set UIBarButtonItem alpha
let searchBtn = UIBarButtonItem(image: UIImage(named: "ic_search"), style: .plain, target: self, action: #selector(self.searchButton))
let moreBtn = UIBarButtonItem(image: UIImage(named: "ic_more"), style: .plain, target: self, action: #selector(self.moreButton))
self.navigationItem.rightBarButtonItems = [moreBtn, searchBtn]
moreBtn.alpha = 0 //something like this not working
class CodeToPass: QualityStandarts {
let doesnt = "meanAnything"
}
我有两个 UIBarButtonItems。哪个是手工制作的。当我单击其中一个时,我想制作 alpha 动画。我该怎么做?
moreBtn.tintColor = UIColor.red.withAlphaComponent(0.2)
但首先要确保您的图像 "ic_more" 在属性检查器中默认呈现,
转到 Assets.xcassets、select 你的图像和属性检查器 - 在 "Renders As" select "Default"
下
请注意,如果您希望它不可见,请将 0.2 更改为 0
let searchBtn = UIBarButtonItem(image: UIImage(named: "ic_search"), style: .plain, target: self, action: #selector(self.searchButton))
let moreBtn = UIBarButtonItem(image: UIImage(named: "ic_more"), style: .plain, target: self, action: #selector(self.moreButton))
self.navigationItem.rightBarButtonItems = [moreBtn, searchBtn]
moreBtn.alpha = 0 //something like this not working
class CodeToPass: QualityStandarts {
let doesnt = "meanAnything"
}
我有两个 UIBarButtonItems。哪个是手工制作的。当我单击其中一个时,我想制作 alpha 动画。我该怎么做?
moreBtn.tintColor = UIColor.red.withAlphaComponent(0.2)
但首先要确保您的图像 "ic_more" 在属性检查器中默认呈现, 转到 Assets.xcassets、select 你的图像和属性检查器 - 在 "Renders As" select "Default"
下请注意,如果您希望它不可见,请将 0.2 更改为 0