UIDocumentPickerController does not occupy entire screen in IOS14 - 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

Related

Swift PHPicker cancel button changes color

I am currently using the PHPicker from apple. Works great but whenever I switch to the album segment the cancel button changes colour to white, making it barely visible. When I switch back to all it stays white. Like so:
code to initialise the picker:
var config = PHPickerConfiguration(photoLibrary: .shared())
config.selectionLimit = 50
config.filter = .images
let vc = PHPickerViewController(configuration: config)
vc.delegate = self
present(vc, animated: true, completion: nil)
Any idea?

How to adjust the size of presented view - Swift 5 (Xcode)

I have a button which will lead a to collection view controller drawDetails_VC.
func showController() {
let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
navigationController?.navigationBar.tintColor = UIColor.white
let navController = CustomNavigationController(rootViewController: drawDetails_VC)
present(navController, animated: true, completion: nil)
}
After updating to Swift 5, the presented collection view Page Sheet is not covering the full screen.
I tried hours but didn't get what I want.
How can the presented sheet Page Sheet cover the whole screen and not as above image.
And how can I get programmaticlly the width of the presented Controller Page Sheet
Set your view controller's modal presentation style to .fullScreen or .overFullScreen. Try the code example below.
func showController() {
let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
navigationController?.navigationBar.tintColor = .white
let navController = CustomNavigationController(rootViewController: drawDetails_VC)
navController.modalPresentationStyle = .fullScreen
present(navController, animated: true, completion: nil)
}

Change Background Color of modal view

I would like to resent an viewcontroller as modal view in size .formSheet. The background color should not be grey transparent, it should be an blur effect.
How I cloud change the background color of view behind modal.
let storyboard = UIStoryboard(name: "DetailViewController", bundle: nil)
if let modalViewController = storyboard.instantiateInitialViewController() as? DetailViewController {
self.definesPresentationContext = true
self.providesPresentationContextTransitionStyle = true
modalViewController.item = item
modalViewController.modalPresentationStyle = .formSheet
modalViewController.modalPresentationCapturesStatusBarAppearance = true
self.present(modalViewController, animated: true, completion: nil)
}
From the viewWillAppear(:) method of your modalViewController, you can access the self.presentationController?.containerView property. You can either change the background color or even add a blur effect view if you want.

Black tab bar appears while pushing SFSafariViewController

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

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)

Resources