我正在使用SFSafariViewController,并且因为我不想显示safari的状态栏,所以我通过添加叠加层来隐藏它。我在覆盖层上有自己的按钮,并且工作正常。 Safari浏览器状态栏是隐藏的,它显示我的覆盖图,但不知何故,有时覆盖层消失,Safari浏览器状态栏可见。我怀疑它是因为链接自动重新加载,但是如何?我只调用一次。我不知道为什么叠加层有时候会消失。下面是我的代码 -SFSafariViewController:Overlay有时不会出现
self.navigationController?.presentViewController(sfController!, animated: true, completion: {
let bounds = UIScreen.mainScreen().bounds
let overlay = UIView(frame: CGRect(x: 0, y: 0, width: bounds.size.width, height: 65))
overlay.backgroundColor = UIColor(netHex: 0x275E37)
let completedBtn = UIButton()
let favBtn = UIButton()
let image = UIImage(named: "home.png") as UIImage?
let homeBtn = UIButton(type: UIButtonType.Custom) as UIButton
homeBtn.frame = CGRectMake(20, 25, 35, 35)
homeBtn.setImage(image, forState: .Normal)
homeBtn.addTarget(self, action: #selector(DetailsViewController.HomeBtnAction), forControlEvents:.TouchUpInside)
completedBtn.setTitle("Mark as Completed",forState: .Normal)
completedBtn.titleLabel!.font = UIFont(name: "FidelitySans-Regular", size: 20)
completedBtn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
completedBtn.frame = CGRectMake((bounds.size.width - 210), 25, 200, 35)
completedBtn.backgroundColor = UIColor(netHex: 0x6F9824)
completedBtn.addTarget(self, action: #selector(DetailsViewController.CompletedAction), forControlEvents: UIControlEvents.TouchUpInside)
favBtn.setTitle("Save as Favorite", forState: .Normal)
favBtn.titleLabel!.font = UIFont(name: "FidelitySans-Regular", size: 20)
favBtn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
favBtn.frame = CGRectMake((bounds.size.width - 420), 25, 200, 35)
favBtn.backgroundColor = UIColor(netHex: 0x6F9824)
favBtn.addTarget(self, action: #selector(DetailsViewController.FavoriteAction), forControlEvents: UIControlEvents.TouchUpInside)
overlay.addSubview(favBtn)
overlay.addSubview(completedBtn)
overlay.addSubview(homeBtn)
self.sfController!.view.addSubview(overlay)
})
任何帮助将不胜感激,因为我长时间停留在这个问题和不能很好的解决方案。谢谢!
我有一个情景,由于我不能使用webview。我必须使用safari。 –