How do I identify a blended layer in iOS? - ios

I am triggering an iOS animation to move some elements around on my screen, and when I do so, an area at the bottom of the screen (away from where I think I'm doing the operation) changes shade slightly. When I turn on 'show blended layers' in the iPhone simulator, it's clear that at the beginning of my animation, something starts overlaying that area, but I cannot figure out what. The view that I'm adding to my screen is a composite view, including a scrollview and an overlay -- something in there is overflowing the bounds it should be in, and I can't figure out what. The simulator obviously knows what it is -- it's happy to color it red for me as a blended layer -- but I can't get it to tell me what layer is being blended so I can fix it. How do I do this?
ETA: If I turn on clipsToBounds on the inserted view, my problem goes away. But I'd still like to know how to identify layered views when I'm trying to debug. Is there a way?

Try animating it all, but each time hide one more subview until one moment, when a subview is removed and problem is no longer visible - You will know which view is faulty.
Better is to go [view subviews] - to really access them all.

Related

How to minimize visual flickering with iOS8 "UIVisualEffectView with Blur"

I have a particular app that, because of the navigation structure, leaves me unable to use normal UINavigationBars with translucency, so I've chosen to try and use iOS8's UIVisualEffectView with Blur.
This solution mostly works, but there is a very noticeable flickering effect that occurs when the UITableView beneath this blur view is scrolled around. As the edges of an image or colored rect pass underneath the blur view, there is a significant amount of flickering that occurs.
Has anyone experienced this? Anyone know how to solve this problem?
My implementation is simple, I dragged a UIVisualEffectView onto my view controller and constrained it to top, left, and right screen bounds, and added a height constraint of 64. Beneath that is just a UITableView with some images and text.
"I assume that what’s not under the view is not being taken into account to compute the blur. It is likely being extrapolated (by padding the image by mirroring, replicating, wrapping, etc… as you would do to minimize boundary effects on any convolution). But this creates an undesired visual jump in many cases.
If you want to minimize this artifact, just make the
UIVisualEffectView bigger than your view. A few pixels will suffice,
the blurring kernel is not that big anyway. And make your view to clip
to bounds."
Reference: https://medium.com/#imho_ios/avoid-artifacts-on-uiblureffect-edges-c30e737c21fb
This worked for me, at least eliminated the bottom flickering in the Navigation Bar. However, it did not work at the top. I believe that is due to view (maybe UIWindow?) clipping against - in my case - the tableView.
UPDATE:
It seems the bug are fixed in iOS 9.0 and later.
I make an uiview which alpha is 0 and add blurview as subview of that. So i can minimize that flickering problem also can hide/show or rounding corners it with animation.

UITextView after CATransform3D: scrolling all out of whack

So I have a UITextView, and in viewDidLoad I rotate its layer so it appears to be slanted back into the screen (sort of like the Star Wars opening crawl).
The problem is that scrolling is all messed up. Dragging up will scroll for a bit, then jump backward or similar; on the simulator it will even crash sometimes with an error about a coordinate containing NaN.
Similarly, when I try to automatically scroll the UITextView via [UIView animateWithDuration:...] I also get unexpected skips, jerks, etc.
I assume this has something to do with the fact that I've manipulated the layer, but the touch events as well as the animations are registered on the view... Or something like that?
Anyway, I'm pretty stumped.
Are you using constraints to position the text view? There seem to be issues with using transformations and constraints together. A common workaround seems to be to wrap the offending item in another view. The big issues are on iOS7, but some applies to iOS8 as well. This link discusses the issues which may be your issue:
How do I adjust the anchor point of a CALayer, when Auto Layout is being used?

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.

How to apply UIView shifts when scrolling between pages

i'm trying to apply a shift effect to subviews of a UIView, but those shifts should'n have the same phase. A good example of that is the welcome screen in SoundClound.
As you can see, in the second image i'm scrolling to the second page, and the label slides more than the image (so it looks that the label moves faster than the image). So the subviews lose the alignment when scrolling, but recover it back if we stop the swipe.
Does anyone know how this effect is named? and where can i find some help to implement it?
Thanks a lot!
"Parallax scrolling" is what you want to search for.
Basically it is done by moving foreground objects faster background objects to simulate depth.
Check out http://blog.denivip.ru/index.php/2013/08/parallax-in-ios-applications/?lang=en for a starting point!

UIPopoverBackgroundView border shrink

I have subclassed and am using UIPopoverBackgroundView in order to make custom appearances for my UIPopoverControllers. Everything seems to work great so far, the popover draws well and looks the way I expect it.
The issue is that, when my popover is left open for a period of time with no activity, the border will often suddenly be drawn wrong. This specifically seems to only happen when the popover contains a scrollview/tableview which is larger than the popover (i.e. it is scrollable). It also doesn't happen every time, but if it does happen, it occurs in less than one minute of inactivity. If I take a screenshot, the issue is not visible (despite it clearly being seen on screen) so I can't provide any images of the issue unfortunately.
Does anyone know of any reason why the border would be drawn incorrectly after several seconds of inactivity and how to fix the issue? I can provide snippets of code if necessary, though I'm fairly certain everything is right (and equivalent to the many examples I've seen online). I also do not resize the popover at any time during the inactivity (I do resize when initially displayed to fit the content up to a maximum size).
Since I can't take a screenshot to demonstrate the issue, the best I can do is describe it. It appears as if the border in certain areas is drawn at the wrong size (as in, part of the right edge is being drawn in the middle of the popover; NOT that the border itself is too wide, but rather that the area the border should be bordering is wrong). The area along the actual edge is still there, but is lacking it's layer effects (I have the backgroundView using a border and rounded corner layer effect to give it a nice rounded white edge, emulating the same appearance as the default background view, just a different color). Removing the layer effects does not prevent the issue though. Sometimes it's only a part of the right edge which is drawn incorrectly, sometimes part of the bottom edge is also affected. I can't seem to find any correlation as to when or how this happens (though it is frequent), nor to which edge is affected (though I've never seen it affect the top or left edge).
Does it only happen in the simulator or also on a real device?
This specifically seems to only happen when the popover contains a scrollview/tableview which is larger than the popover (i.e. it is scrollable)
Do you resize the scrollview / tableview in this case? Try adding a UIView inside your UIPopView that would be the container.

Resources