我正在创建一个用于跟踪健康信息的应用程序,我想使用 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!)
更奇怪的是,当我进入断点时,图像居然显示出来了!我也附上了这张照片。感谢我能得到的任何帮助。谢谢!