You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何隐藏SFSafariViewController右下角的外部浏览器打开图标?

解决SFSafariViewController隐藏外部浏览器图标的问题

不需要重新实现整个视图,有两种简便方法可以实现需求:

方法一:切换为全屏展示(兼容所有iOS版本)

把modalPresentationStyle从.pageSheet改成.fullScreen,全屏模式下SFSafariViewController不会显示右下角的外部打开图标:

if let url = URL(string: "[URL]") {
    let vc = SFSafariViewController(url: url)
    vc.modalPresentationStyle = .fullScreen
    vc.dismissButtonStyle = .cancel
    present(vc, animated: true)
}

方法二:利用配置项禁用外部打开(iOS 16+适用)

iOS 16及以上版本可以通过SFSafariViewController.Configuration的allowsOpeningInBrowser属性直接禁用外部打开功能,同时隐藏对应图标:

if let url = URL(string: "[URL]") {
    var configuration = SFSafariViewController.Configuration()
    configuration.allowsOpeningInBrowser = false
    let vc = SFSafariViewController(url: url, configuration: configuration)
    vc.modalPresentationStyle = .pageSheet
    vc.dismissButtonStyle = .cancel
    present(vc, animated: true)
}

内容的提问来源于stack exchange,提问作者tomblixt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 09:42:10