我正在尝试将图像放置在SFSafariVC的屏幕底部上,该图像将具有与设备进行交互的按钮。我已经毫无问题地添加了SafariViewController,但是我不知道如何添加图像,任何帮助或建议都将不胜感激。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("row selected: \(filteredTable[indexPath.row])")
let selURL = URL(string: "https://www.google.com/")
let selSite = SFSafariViewController(url: selURL!)
present(selSite, animated: true, completion: nil)
selSite.delegate = self as? SFSafariViewControllerDelegate
}
参考代码
答案 0 :(得分:0)
我不确定该解决方案是否是您想要的,但是在某些情况下,您无权访问视图控制器以添加视图,您可以将视图添加到关键窗口中;
更新
guard let url = URL(string: "https://google.com/") else {
return //be safe
}
let svc = SFSafariViewController(url: url)
self.present(svc, animated: true, completion: nil)
let image = UIImage(named: "img")
let imgV = UIImageView(image: image)
imgV.frame = CGRect(x: 0, y: UIScreen.main.bounds.size.height - 30, width: UIScreen.main.bounds.size.width, height: 30)
UIApplication.shared.keyWindow?.addSubview(imgV)
通过此代码,图像将显示在safari视图上,而无需您执行任何操作(已测试)