Weird UIView rendering issue - ios

I'm facing a really weird problem with a UIView (as seen in the attached screenshot).
Basically there is a UIView with a backgroundColor that has an alpha of 0.9 (the dark blue area). Within that view there is some text, and another UIView (the circle). I've got an NSTimer that runs every second to count down that middle number (16), however for some reason, after about 3 seconds the dark blue area becomes 100% transparent (only in certain areas, e.g. the light blue with dots, and the 'records' section) and shows the UI elements in a completely different view. If I remove the alpha transparency on the backgroundColor, everything continues to render correctly and this issue doesn't occur.
Any suggestions? I've tried forcing it to redraw the UIView, tried adding another UIView and setting the background of that as well.
EDIT: It's also occurring with a 3rd party library not written by me (the alert window).

Add an assert in your timer handling method to insure you are on the main thread when you deal with the UI (see NSThread).
Also why are you adding views to the key window and not to your root view? The system moves windows in the Z plane.

Related

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.

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.

Pixelated text in UILabel within UIScrollView, both with transparent background

I have a weird issue:
I have a UIScrollView whose background is transparent. Inside of it there are a few UILabels also with a transparent background and with a custom font.
When the scrollview is first displayed everything looks sharp and good but as soon as I start panning the scroll view, the text of the labels gets extremely pixelated.
This does not happen if i set an opaque background to the labels.
Do you have any idea what might be causing this?
This sounds like you may be adding several layers of the identical UILabel on top of the others on scroll. Place a debug breakpoint on the code that adds it to your content, and ensure it is only being called once.
The "pixelation" could be caused by the overlapping of anti-aliasing pixels.

Scrolling a tableview inside a popover creates an artifact

If you look at the button/label titled "Address" you'll notice a little speck of white in the corner. This speck of white only occurs when the user starts scrolling the tableView, which is located underneath the searchbar.
I can only guess that the modal border kills all transparencies while scrolling.
This is an iOS issue with regards to scroll view and is seen in many places - no solution other than you reducing or creating some offset for the tableview.
this artifact could be caused by a variety of different things. The first things I would check when seeing these things is that all of the UIViews (and there subviews) that overlap this area
A. Have a background color with an alpha value of 0
B. Have "Cear Graphics Context" turned off in Interface Builder (or corresponding flag in code)

UIPopOver, UITextView and automatic resizing

I've got an app where I allow the user to add events to a list. The method I use to do this is via a form that I show the user in a UIPopOver.
The form has the following components (in this order, top to bottom):
Event Description Label (UILabel)
Event Description (UITextField)
Event Details Label (UILabel)
Event Details (UITextView)
Event Time Label (UILabel)
Event Time (UIDatePicker)
Save Event (Custom Button)
Cancel (Custom Button)
I'd prefer not to show a screen shot since it's a sensitive app. :-)
So........
All is well when I first show the UIPopOver. Everything appears as I wish. The overall layout is about 650 pixels tall, which is just tall enough to take up pretty much the whole screen (vertically) when in landscape mode.
When the user tries to interact with the `UIDatePicker`, everything goes swimmingly (well).
When the user taps into the Event Description (`UITextField`) field, the keyboard appears and the `UIPopOver` shrinks so that basically the `UIDatePicker` and buttons are hidden. I consider this OK, since they re-appear when the keyboard is dismissed.
The problem I am having is when the user tries to interact with the `UITextView`:
When the view of the `UIPopOver` has its `backgroundColor` property set to `[UIColor whiteColor]`, the `UITextView` initially appears with a thin black border. I like this.
When the user taps in the `UITextView` to begin editing, the `UIPopOver` resizes to accommodate the keyboard and, during the transition, the black border "shrinks up" and disappears. This is in spite of my shocks and struts being set so that all dimensions/directions are fixed and it is "glued" to the top-left.
Following this, when the user dismisses the keyboard, the border sort of restores itself to its previous position, but it now adds a thick black border on the bottom that completely obscures the label placed between the `UITextView` and the `UIDatePicker`.
When I change the background of the view of the `UIPopOver` to "`ScrollView` Textured Background Color", the border "disappearing trick" is at least less noticeable, but the black border at the bottom (following keyboard dismissal) is still present.
Questions
Has anyone encountered something like this before?
Does anyone think it's just an IB error and that I need to re-build my XIB?
Anybody got any other ideas? Googling for this issue came up fairly empty for me. If you think of better terms and find something, please let me know (gently).
Boy, I'm a stupid stupid!!! It turns out I had forgotten that I placed the UITextView inside of a UIView (inset 1 pixel on all sides) and set the background of the UIView to be black so that I could get a border effect on the UITextView. Once I remembered that, setting the shocks/struts of THAT UIView turned out to be the solution.
Sorry for wasting your time!

Resources