I have a UIView with many subviews on a UIScrollView. As the UIScrollView slides to the left off the screen the alpha value of the UIView is reduced. It eventually is almost 0.0.

The issue is that once the alpha of the UIView is less than 1.0 I can see all the subviews sides and the one that gets me the most is the outline of an UIImageView can be seen that would otherwise not as it is the same colour as the UIView.

I thought the answer would be UIView.layer.ShouldRastersize = YES; however this is not suitable for a moving view and in any case the whole view looks shocking.

So how should I be doing this?

有帮助吗?

解决方案 2

I figured this out. I needed this;

myView.layer.shouldRasterize = YES;
myView.layer.rasterizationScale = [[UIScreen mainScreen] scale];

If I understand the whole thing correctly they should be only used where necessary and then later turned off. So while sliding it is Yes and as soon as I stop it is NO.

其他提示

Well, I think I did something similar, replicated a lightbox effect on iOS.

What I did was I quickly faded out the subviews first, then I fade out the containing parent view.

It looked more nicer that way as I don't see the background fading but the subviews sticking out like a sore thumb.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top