gpt4 book ai didi

ios - 图标及其颜色自动更新 | iOS |碳套件

转载 作者:行者123 更新时间:2023-11-30 11:58:51 25 4
gpt4 key购买 nike

我在代码中使用 CarbonTabSwipeNavigation(如下所示)。问题是所有图标的颜色都会自动更新(可能会更新为某种默认颜色)。如何解决这个问题?除此之外,我的一个图标正在更新(不知道为什么)。我尝试在应用程序的其他部分使用相同的图标,效果非常好。请帮助我。谢谢

weak var tab: CarbonTabSwipeNavigation!

override func viewDidLoad() {
super.viewDidLoad()
let iconNames = ["icn_events", "icn_places", "icn_activities", "icn_clubs"]
var images = [UIImage]()

for icon in iconNames {
if let img = UIImage(named: icon) {
images.append(img)
}
}

let carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: images, delegate: self)
carbonTabSwipeNavigation.pagesScrollView?.isScrollEnabled = false
carbonTabSwipeNavigation.insert(intoRootViewController: self)

//I'm using following piece of code to fix the color issue (please note, even without this, the image is being updated).
//carbonTabSwipeNavigation.setNormalColor(UIColor(hex: "5603ad"))
//carbonTabSwipeNavigation.setSelectedColor(UIColor(hex: "5603ad"))

carbonTabSwipeNavigation.setTabExtraWidth(45)

tab = carbonTabSwipeNavigation
}

我已附上实际的图标及其显示方式的屏幕截图。

enter image description here

最佳答案

发生这种情况是因为条形颜色。该问题已通过图像渲染模式修复:

let iconNames = ["icn_events", "icn_places", "icn_activities"]
var images = [UIImage]()

for icon in iconNames {
if let img = UIImage(named: icon) {
images.append(img)
}
}

if let img = UIImage(named: "icn_clubs")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal) {
images.append(img)
}

关于ios - 图标及其颜色自动更新 | iOS |碳套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47483086/

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