Changing the iOS 13 UIPopoverPresentationController blur and shadow amount? - uipopovercontroller

The appearance of the modal popover view shown by the UIPopoverPresentationController in iOS 13 has changed significantly from how it looked in iOS 12. The base color is darker, the shadowing of the background is different, and the amount of blurring of the background under the popover is very different.
If I was setting the background of my popover content to a solid, non-alpha-transparent color, I wouldn't have any issues, but I am, and I cannot figure out how to access the view/layer which my content is being displayed in to change things.
Setting the backgroundColor of the UIPopoverPresentationController to something completely transparent (alpha = 0.0) doesn't give me a completely transparent popover. I implemented a UIPopoverPresentationControllerDelegate and tried to use the prepareForPopoverPresentation: method to access the view the popover content is inside of, and make modifications, but I can't seem to find it: superview() is nil, and the UIPopoverPresentationController.presentedView() is also nil (at least they are when that delegate method is called). The UIPopoverPresentationController.containerView() is not nil, and definitely is the overlay view in which the popover is displayed...but that isn't the view I'm looking for.
So...I'm wondering what I'm missing here. I would very much prefer not to have to implement my own UIPopoverBackgroundView as the popoverBackgroundViewClass though I know that is a possibility.

Related

Set navigationbar size according to background image

I have set an backgroundImage for my navigationbar. This works fine. But I would like to have the navigationbar height to be adjusted to the background image. At the moment the width of the background images is also not set according to the screen size.
I tried setting the height of the navigationbar like described here. This shows a bigger navigationbar for like a second but then it shrinks to its default size again.
Does anyone know how to achieve what I want? Here is an example of what I want to achieve: image
Apple Documentation:
It is permissible to customize the appearance of the navigation bar
using the methods and properties of the UINavigationBar class but you
must never change its frame, bounds, or alpha values or modify its
view hierarchy directly.
To achieve the effect seen in the image you tagged, they are most likely using a collection view to layout their data and that image is part of the collection view's header. They made the navigation bar background color clear, but the image is definitely not part of the navigation bar itself.
Apple recommends to never change the frame of a navigation bar manually because it messes with the layout code of its subviews and animation methods.
You could either subclass the navigation bar and attempt to create something similar, or go the easier route and make the navigation bar clear (UIColor(white: 0, alpha: 1) not .clear otherwise it might show up incorrectly) and have an underlying view display the image (e.x. a collection view whos header extends to the top of the view controller).
This will allow you to adjust the image height and width freely without subclassing the navigation bar, and creating potential bugs.
You can make custom NavigationBar class.
It can be help you
https://developer.apple.com/library/archive/samplecode/NavBar/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007418-Intro-DontLinkElementID_2

How to change UIPopoverPresentationController's arrow color without drawing my own

I want to change the color of the arrow that UIPopoverPresentationController uses to point at its source. The only way I can see to do this is to subclass UIPopoverBackgroundView and write drawRect and draw the popover border and arrow myself. That's a pain, because there are little niceties in the default popover like rounded corners on everything. And I want to make it feel as much at home on the platform as I can.
Do I really have to draw my own popover arrow just to change the color of the arrow?
Update: I've tried setting the backgroundColor of the UIPopoverPresentationController, but it appears to change the color of everywhere the arrow might draw. I've seen it work before, but I can't nail down what makes it work when it does. See screenshot of setting the color to red. The blue is the content of the navigation controller in the popover. It's supposed to be pointing at the button.
The UIPopoverPresentationController's backgroundColor property should handle that for you
Update
I've used this approach a number of times and have never seen what you have in your screenshot. Are you sure you are using popoverPresentationController.backgroundColor and not setting a different background color on a view or container? Below is screenshot of non-centered popover arrow. The view controller background is green, the popoverPresentationController.backgroundColor is red. Shown next to the code setting the value.
Update #2
I looked at the project you posted and found the problem (although I'm not entirely sure why it's the problem). You are setting the popover presentation controller's backgroundColor property inside your presented view controller under viewWillAppear:. I suspect that setting the background color like this after the presentation happened is what triggers the bug pre-iOS 10.
If you set the popover presentation controller's backgroundColor inside your presenting view controller's onPopover: method, where you are also setting the sourceView and sourceRect properties (and before you actually call presentViewController:), everything works correctly.

How to specify vibrant appearance for secondary Today Centre widget text?

I am working on my first Today Centre widget, which simply consists of three labels on the default storyboard. It's working fine, but I read in the iOS Human Interface Guidelines that secondary text should "use the system-provided vibrant appearance" with notificationCenterVibrancyEffect.
What's the correct way to add this vibrancy effect to my two secondary labels? I've read about UIVisualEffectView, but it's still not clear to me how to use it for this purpose. I don't think I want to put a blurred view behind my labels because Notification Centre already blurs the background.
UIVisualEffectView when configured with a UIVibrancyEffect is meant to be used as a container—just drop your labels in its contentView and you’ll get the appropriate appearance on top of the Notification Center blur. The text color doesn’t matter; when it’s added to the contentView it gets special treatment and effectively always renders with the same appearance, though you can still adjust the alpha of the view (not of the text color) to make it more or less prominent.
good day, first of all u should use a correct view hierarchy, when U add some objects in your VisualEffectView example:
UIVibrancyEffect used in combination with UIVisualEffectView, adjusts the colors of the content to make it feel more transparent. UIVibrancyEffect can blending some objects
with the background example:
More particularly to your question(https://stackoverflow.com/a/25392645/4912496) Apple recommends to use vibrant effect for secondary text, because its simply beautiful for example(apple native app use vibrant effect, and Sports.ru don't use it):
But, some apps don't use this effect...
To ensure that your widget gets the vibrancy effect that’s appropriate for displaying items in the Today view, use notificationCenterVibrancyEffect.
Some info. https://www.omnigroup.com/developer/how-to-make-text-in-a-uivisualeffectview-readable-on-any-background

UINavigationController toolbar 100% transparent

In a storyboard I create a ![UINavigationController] with its root view controller a UIViewcontroller. In the toolbar I have a segmented control. I made it transparent, but only has the normal tint, I expect to see the normal background or the table view blurred under it, but its 100% transparent for some reason.
This is a known bug in iOS7, when presenting a popover from a bar button item.
First open a bug report so Apple gives this issue more priority.
As a workaround, make sure to set the edges for extended layout to none for view controllers inside popovers. For reference, you can see in Apple's calendar app they also do this. There is no translucency under popover navigation bars and toolbars.

Disable the shadow on UIPopoverViewController's content view

I'm creating a custom popover for a UIPopoverController by subclassing UIViewController to manage the content view and UIPopoverBackgroundView for a custom background. Everything works great, except the UIPopoverController is applying a shadow to the content view, making the content appear bordered with shadow. I can't seem to find which view's layer is shadowed. How can I disable this shadow? Has anyone else ran into this problem?
As this is still standing months later, I'll close this by saying I implemented my own popup controller. It's a shame, though, one would think there would be a better way...

Resources