Black tab bar appears while pushing SFSafariViewController - ios

I'm using the following code to present an SFSafariViewController
let url = "https://stackoverflow.com"
let safariViewController = SFSafariViewController(url: url)
safariViewController.modalPresentationStyle = .fullScreen
safariViewController.modalTransitionStyle = .crossDissolve
self.navigationController?.present(safariViewController, animated: true)
For some reason, there is a glitch in the SFSafariViewController upon presenting. Any ideas?

I've found my problem
My UINavigationBar style was set to black
UINavigationBar.appearance().barStyle = .black

Related

UIDocumentPickerController does not occupy entire screen in IOS14

I am using following code to import files,
if #available(iOS 14, *) {
let supportedTypes: [UTType] = [UTType.text, UTType.data]
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)
}
In the output we can see transparent view between "Recent/Browser" tab bar and document content view.
Here is the screenshot of the output:
image 1
image 2
If I change the presentation style to fullScreen, transparent view will become grey coloured view
documentPicker.modalPresentationStyle = .fullScreen
Here is the screenshot of the fullScreen output:
image 3
image 4
Does anyone know how to resolve this?
Check UITabBar.appearance().isTranslucent property.
I had the same problem when this property was false

iOS13: PopoverPresentationController - the border on the arrow side is missing

In the same theme as this post:
ios13 UIPopoverViewController showing UITableViewController - Safe Area problems / Missing parts of table
But in my case, it is not especially a UITableViewControllerany any View Controller in a popover on the iPad has the same issue since iOS13.
I have no problem with overlapping content, just the border.
App screenshot
let popoverContent = self.storyboard!.instantiateViewController(withIdentifier: controllerName) as! SelectSceneViewController
popoverContent.preferredContentSize = CGSize(width: 700,height: 500)
let nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.popover
nav.navigationBar.barStyle = navbarStyle
nav.view.layer.cornerRadius = 10
nav.view.layer.borderColor = UIColor.white.cgColor
nav.view.layer.borderWidth = 2
let popover = nav.popoverPresentationController
popover?.sourceView = button
popover?.sourceRect = button.bounds
self.present(nav, animated: true, completion: nil)
I have found the answer. I have to implement my own UIPopoverBackgroundView.
Example: https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch09p476popovers/ch22p751popovers/MyPopoverBackgroundView.swift
Andrew Shepard has implemented a great UIPopoverBackgroundView:
https://gist.github.com/andyshep/6240110
https://andyshep.org/2013/08/2013-08-10-implementing-drawrect-on-uipopoverbackgroundview/

present ViewController calling viewWillDisappear but does not call viewWillAppear

Following is my code present safari view controller
if let url = URL(string: "https://www.ggogle.com.com/") {
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true
let vc = SFSafariViewController(url: url, configuration: config)
present(vc, animated: false)
}
Above code calls viewWillDisappear but does not call viewWillAppear when presented view controller is dismissed.
Also found that after view is dismissed viewWillDisappear is not called at all for any other pushViewController
How to fix this?
Update on this:
Tried navigation controller and set its delegate and implemented following methods
navigationController:willShowViewController:animated:
navigationController:didShowViewController:animated:
This is not working as well.
Update on this tried following code
vc.modalPresentationStyle = .currentContext
But using this tab bar does not hides and controller not appearing full screen and there is no option like hide bottom bar on present.
Please try this
if let url = URL(string: "https://www.google.com/") {
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true
let vc = SFSafariViewController(url: url, configuration: config)
vc.modalPresentationStyle = .currentContext
present(vc, animated: false)
}
UPDATE
vc.modalPresentationStyle = .currentContext
tabBarController?.present(viewController, animated: false, completion: nil)

Swift ViewController Background getting black with alpha

I'm calling a ViewController as popover when the user presses a button. The View should have black background with alpha 0.5.
But the View is shown as that for a second, than the whole background turns black without alpha. Any idea why?
Thats my popover call:
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .popover
self.present(popOver, animated: true, completion: nil)
I'm trying to set the background color in popovers viewDidLoad() function with following code:
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
For that set modalPresentationStyle to overCurrentContext instead of popover.
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .overCurrentContext
self.present(popOver, animated: true)

Background not transparent when modal is in NavigationController

I'm having a viewcontroller that has a blurview as background so that you can see the underlying viewcontroller.
This works great except when you want to present the modalviewcontroller in a navigationController. Then you see the blurview for a sec and then it is just white and you can't see the underlying viewcontroller.
I tried to set the navigationcontroller.view.backgroundColor to clear but this doesn't work.
How can I achieve this?
let vc: FilterViewController = FilterViewController()
vc.modalPresentationStyle = .overFullScreen
vc.delegate = self
let navCtrl = UINavigationController(rootViewController: vc)
navCtrl.view.backgroundColor = .clear
self.navigationController?.present(navCtrl, animated: true, completion: nil)
you want a screen to blur another screen? it's not so easy but possible...
it's a bit difficult to paste this here, so will give you a link

Resources