gpt4 book ai didi

ios - SF 符号未加载到 UIImageView

转载 作者:行者123 更新时间:2023-12-01 15:44:24 24 4
gpt4 key购买 nike

我正在创建一个跟踪健康信息的应用程序,我想使用 SF Symbols 的两个箭头图像。不幸的是,无论我怎样尝试,这些符号都不会出现。我已经用 Assets 文件夹中的图像测试了代码,它在我创建的 UIImageViews 中似乎没有问题。只有当我尝试使用 UIImage(systemName: ) 时我才会遇到问题。

        self.calendarView = UIView(frame: CGRect(x: 0, y: self.getCurrentY(), width: UIScreen.main.bounds.width, height: 60))
self.calendarView?.backgroundColor = .white
self.calendarView?.layer.borderColor = UIColor.black.cgColor
self.calendarView?.layer.borderWidth = 1

self.currentDate = UILabel(frame: CGRect(x: self.calendarView!.bounds.width / 4, y: self.calendarView!.bounds.height / 2 - 20, width: self.calendarView!.bounds.width / 2, height: 40))
self.currentDate!.text = "5/6/20"
self.currentDate!.textColor = .black
self.currentDate!.layer.borderColor = UIColor.black.cgColor
self.currentDate?.layer.borderWidth = 1
self.currentDate?.textAlignment = .center
self.calendarView?.addSubview(currentDate!)

//let testImage = UIImage(named: "logotest.jpg")!
let image1 = UIImage(systemName: "arrow.left")!.withTintColor(.blue)
let image2 = UIImage(systemName: "arrow.right")!.withTintColor(.blue)

self.leftArrow = UIImageView(image: image1)
self.rightArrow = UIImageView(image: image2)

self.leftArrow?.frame = CGRect(x: 10, y: 10, width: 40, height: 40)
self.rightArrow?.frame = CGRect(x: UIScreen.main.bounds.width - 50, y: 10, width: 40, height: 40)

self.leftArrow?.layer.borderWidth = 1
self.rightArrow?.layer.borderWidth = 1

self.calendarView!.addSubview(self.leftArrow!)
self.calendarView!.addSubview(self.rightArrow!)
self.contentView.addSubview(self.calendarView!)

更奇怪的是,当我进入断点时,图像竟然显示出来了!我也附上了这张照片。感谢我能得到的任何帮助。谢谢!

enter image description here

enter image description here

最佳答案

为您的 imageViews 着色将解决问题

leftArrow.tintColor = .blue 
leftArrow.tintColor = .blue

关于ios - SF 符号未加载到 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61642892/

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