I built a custom Popoverview, but fail to remove the content's rounded corners.
Tried to set .layer.cornerRadius = 0.0 in almost every view in found, with no success.
Image Link: Custom Popover
Red border is of UIViewController used to init the UIPopoverController with, green is background of custom UIPopoverBackgroundView.
Answer from this thread: UIView default styling has rounded corners?
There is no supported way to make the view inside of your UIPopoverController not have rounded corners. The internal code of the UIPopoverController adds your view to a view with rounded corners that clips to bounds.
There may be a hackish way to do it, i.e. waiting until the UIPopoverController is shown and then traversing through all of the parent's of your view and setting them all to have cornerRadius = 0; and clipsToBounds = NO;, but even if you find a solution it might not be compatible with all versions of iOS and if Apple changes some internal code of UIPopoverController in the future then your solution could break.
If you really want to do this then the best way to go is to create your own class that mimics the UIPopoverController functionality.
Related
In the iOS music app, I've noticed the shadow underneath album artwork changes based on the color of the artwork. This shadow can also be multi-colored based on how the color at the edge of the artwork changes.
Does anyone know how to recreate this effect programmatically?
Thanks to #Josh Homann for pointing me in the right direction, but the answer was actually much more complex.
The first (bottom) UIView in the hierarchy should have a plain white background and be pinned to the edges of the screen.
The next view should be a UIImageView with an alpha of 0.75.
Then you should add a UIVisualEffectView with the same dimensions as the first view.
Finally, add another UIImageView that is the same size as the first UIImageView.
Your IB hierarchy should look similar to this:
The final result is this:
Its not a shadow its a UIVisualEffectView with a blur. Add a second image view under your image view with a larger size and add a blurring visualEffectView to it.
Sorry to revive an old question, but this library nailed it: ShadowImageView.
It uses CIFilter which gives you more control over the blur effect and better results.
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.
I created a UIPickerView that I would like to not have that fade on the edges.
First I thought that must be some kind of gradient overlay so I recursively hid all UIImageViews within the UIPickerView and also set all layer.contents to nil. Setting a background color different to white to the picker view reveals that the fade cannot be an overlay, since the labels in the picker view now fade to the background color.
Does anybody have an idea on how to find that layer mask and turn it off?
EDIT
I just checked if there are any CALayers with masks, but there are none.
This is not exactly the answer to my question but at least a solution. I found a custom (horizontal) AKPickerView on GitHub which is available for Obj-C and Swift (1.2 and 2.0). This View has an undocumented property maskDisabled which does exactly what I need.
Unfortunately it is not completely clear what I am trying to do from the title. I want to create an interactive tutor for my IOS application. At the moment I have a simple UIviewcroller with some images, but I want to make it more interactive. I want to add ontop of my normal UIview a second UIview which is partially transparent to enable the user to see what there is below it, and in some parts, invisible. there are the parts that the user has to touch. on this UIview there will be arrows, labels, and other information. Is this possible? If a UIview is covered by another, can I make it possible for the user to interact with parts of the one below it?
Set view.userInteractionEnabled = NO; to disable interaction.
And view.backgroundColor = [UIColor clearColor]; for a transparent background.
Touches will go right through the view to the next one below it.
EDIT:
Alternatively you could try setting view.alpha = 0.0f;. This will make the view transparent. Then you add any buttons and labels to this view. These buttons will be visible and work as expected, but tapping anywhere else will pass through the transparent view. If alpha is below some threshold (not sure about the exact value), touches are ignored and passed to the next view.
On the subview you want transparent set userInteractionEnabled = FALSE. You can also do the same thing with UIWebVIew, UIImageView, etc. also you can set the background color to UIColor clear color. That way it's see through to the layers below.
Try making top view transparent and add a third view below and make its bg-color black and set alpha 0.5
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...