UIVisualEffect view edge-to-edge do not line up - ios

I want to have a table view with custom cells in it, and with a consistent blurring that moves with the content when scrolling. The easy solution was to have the custom cells contain a UIVisualEffectView.
Unfortunately when I put UIVisualEffectViews next to each other, the edges are noticeable and the blurs do not line up. Does anyone know of a way to fix this so that edge-to-edge UIVisualEffectViews do not show a "seam"?

Related

Is it possible to use a UITableView's cells as a mask for a view underneath it?

I want the background image to only be visible where the individual cells are, so as you scroll it reveals different parts of a fixed image underneath. It's basically the opposite of a common tableview with opaque cells over a background, if that makes sense.
I still want the cells to be rendered normally in addition to their edge serving as a mask boundary, since they'd have text and other subviews that aren't just for masking.
I can't find an example, but I've seen this effect before done using CSS and it looks nice. It's not incredibly complicated, but I can't seem to figure out an efficient way to do it in UIKit.

Disable scrolling on content inset in SwiftUI

I'm trying to create a complex view using SwiftUI.
I'm trying to do a profile view with two scroll views on top of each other. I created wireframes, so it's easier to understand.
Here you can see the red and blue rectangle. They are both scroll views. I'm trying to achieve that the blue rectangle must only be scrollable from its content (blue section) but must be able to cover the whole screen when we scroll on it. See the next two states:
I tried adding some content inset using the library SwiftUIX, but can't seem to find a way to disable the scrolling mechanism on that content inset. So the red section of the wireframes must still be scrollable when scrolling on that area.
I tried only using drag gestures with offset, but the feeling was not as smooth as a scrolling view, and I could not mimic that feeling.
The default Apple implementation for a bottom sheet is not ideal because it works in steps, whereas I need it to be as smooth and controllable as a standard scroll view.
If any of you had any leads or ideas, it would be life-saving. I have spent hours on this and have been able to find a suitable solution.

How to correctly animate change of size of a paged UICollectionView

I have an iPad app similar to the iPad Keynote with a narrow overview on the left and a paged UICollectionView of my "slides" on the right. The collection view is using the default FlowLayout. Some of these slides are standard PDFs and some are embedded UIViewControllers that have been scaled (with a CGAffineTransform) and embedded in the cell. I'd like to smoothly animate the overview sidebar offscreen and zoom the current page cell to fullscreen. The collection view should allow paged swiping at whatever size. I'm using storyboards and autolayout.
I think I need to simultaneously animate about three things:
The collection view constraints (to the sidebar) to enlarge/shrink it
The flow layout's sizeForItemAt: value
The CGAffineTransform on the embedded view controller.
I have some pieces working (a single embedded View Controller "slide" that scales correctly) but cannot get the collectionView/cell resize dance to work correctly. The cell resize animation is jerky, or ends up with the wrong offset, or works for the leftmost cell but not for other cells.
I've tried most of the suggestions in the answers to this question but with no convincing success. I can't believe it's impossible but at this point I'm considering the smoke and mirrors approach of animating a static slide and hiding it after the animation completes. The attached video - ignoring the glitches - illustrates the kind of effect I'm after:
It's worth noting, on close inspection, that Keynote cheats somewhat when it comes to swiping between slides in edit mode, and manually manages the next slide sliding onscreen, so probably doesn't use a UICollectionView.
Has anyone done anything similar, or have any suggestions for things to try?
I managed to solve this. There's a proof-of-concept GitHub repo here.
There are a few moving parts:
There are two pieces of UIView scaling code. I suspect these could be combined with suitable delegate references as the nested view controllers are embedded. The first piece scales (statically) correctly when the Collection View cell is created. The second is an animated scale/translate when the sidebar size is changed.
I added a FlowLayout subclass to remove flicker as the collection's layout is invalidated during scaling.
The sidebar-related transform in the top-level VC uses most of the tricks in the book - invalidateLayout(), performBatchUpdates(...), layoutIfNeeded() etc. as well as animating the contentOffset to the correct value. Some manual tracking of the correct page/slide is required.
There's still a slight flicker occasionally at the start of resizing. This may not be an issue with my particular colour-scheme which will be black on dark gray. Bonus points if anyone can suggest how to track this down or alleviate it.

I've added a view within a UITableView and there is a gap between the view and the first cell. How can I remove it?

I've added a view to a tableView and there is a gap between the view which is 44px high and the first cell.
Here's a screen shot from IB:
I've tried a few things such as changing the heightForHeaderInSection's value and also disabled adjust scroll view insets. None of these work properly. The view seems to be within the tableView and scrolls with it.
This is how things are looking in simulator:
Would appreciate some help here as I don't understand what exactly is causing this gap.
Thanks for your time
A great way to debug these types of problems is to set a background color. You could set the cells to red and the view to green. It would then be interesting to see if the red and green edges are flush with no white in between.
Based on your screenshot, it looks like nothing is wrong. And by that I mean it looks about right for a view height of 44 points and a cell immediately beneath it with no separator line above it (so it's hard to tell where one ends and the other begins).

Want a UIVisualEffectView affected by content above as well as below it?

I have a UIVisualEffectView with a UIBlurEffect effect as a pinned UICollectionViewCell in a UICollectionView.
The blur is masked with an icon so that the icon appears in a subtle shimmery way, responding to whatever it is drawn on top of.
The effect is on top of the collection's background. As it stays pinned and the varying background scrolls underneath, it gently changes to reflect the background and looks very nice.
However, except for the collections's scrolling background, most content is drawn in front of the blur effect. This is necessary because that other content is more important and shouldn't be obscured.
Even though it is behind the more important content, I'd like the effect view to reflect the content that is scrolling in front of it. Any suggestions for how this might be made to work?
Ideas:
Could I grab a chunk from the previously drawn frame and draw this under the effect view? How would I do that?
Could I render the whole collection view, apply the blur, and then render everything that should be on top of the blur a second time? How can I make that efficient?!
Thanks.
I went with a slightly refined version of the second option.
I added some duplicate cells to the collection view that are rendered behind the blur, and then also in front. I've only done this for one of my cell types with lots of colour in it. It works pretty well.
If you have a better approach I'll happily assign you the correct answer.

Resources