Detect if colour beneath UIVisualEffectView is light - ios

Because the UIImageView in the background is very light, you can't see the text in the foreground on top of the UIVisualEffectView. I want to detect whether the background is light or not and if so, change the text colour to something darker. How can I do this?

To detect the dominant color of a UIView it takes two steps. First is to capture the image data of the view as described here: How to capture UIView to UIImage without loss of quality on retina display
Second is to determine what the dominant color of the view is as described here:
How does the algorithm to color the song list in iTunes 11 work?
And then make your adjustments based on the result.
Personally, I would simply use a dark text color for the light blur. Or continue with the light text and use the dark blur effect. Or set a tint color on a navigation bar.

Related

Strange alpha blending with UIImageView on UIView

Currently I'm working on a simple image editor where you can with a brush alter the alpha channel.
My problem is, when a UIImageView with 0 or near zero alpha image is presented on another UIView, that has a dark color (like brown, black, etc), a strange composition appears. Image becomes visible like its alpha has never been changed. When the back UIView is white, everything is normal.
You'll want to say "keep it white" but I'm currently using this UIView as the background canvas and user has the ability to change the color.
The captures I took are from Reveal, but the appearance is exactly the same on device as well. Here is what I mean with all this talk:
This is an image with 20% alpha set to all it's pixels. The image looks ok. From Reveal, I can see that the image has the correct alpha channel. Everyting is as it should be.
Here is the same image with 15% alpha on a darker blue background (sorry, while capturing I changed the alpha). From Reveal, everything is again looking normal.
But when you look at the device, this is what you see. This is the same UIImage with 15% alpha set to all pixels and presented in UIImageView.
The image is fully appearing on the background dark blue UIView, like its alpha is not 15%. Changing alpha when working on a dark background has not much effect. It simply adds blue all over, or 100% alpha returns to the original image. Even when setting the alpha of all pixels to 0, the image is clearly visible.
Is there something I'm missing? Why this composition (or blending of two UIView objects) error/bug/problem appearing? Is there a value that I am forgetting to set? Or is this normal and am I doing something wrong?

Transparent text color in a Today View Widget

I'm trying to get the same color/transparent effect as Apple has used on the bottom borders of table view cells in the today view. How can I also use this effect on for example a UILabel?
How do you get the white transparent effect on a UILabel in a today view widget?
I've wondered the same myself. I think They're setting a color of white with 0.4 alpha on the font and a color of black with 0.4 alpha on the background. They overlay the whole thing over a gaussian-blurred and saturated image of what was previously behind the today view.
So the required steps to produce the same effect would be something like the following:
1. Grab background image
2. Blur and saturate image
3. Add below the current view
4. Set black background of 0.4 alpha and white font of 0.4 alpha on the current view.
If you can think of a way to make the background translucent right behind the font that would make the color show more.
Here's an image of what that would look like (including the translucent background behind the text). I did this real quick in photoshop, don't mind the font.
Hope this helps!

Changing the background color of a captured image from camera to white

I am working on a app in which user captures some images. and than he will change the background color to white. Its same as how FotoFuze.org does. I want to know how to change the background color to white without losing the object data.
For this i go through some of the things like detecting the background color. and editing the pixels whose color is background color to transparent.
But this causing problems if the image itself has some part colored as the background color.
So please suggest me the right way to accomplish this.

Highlight(Overlay) specific area on UIImage

I am developing a book app. Book pages are images. At a time one image is shown on iphone screen. Image contains lines(Paragraphs). I want to highlight the whole paragraph on touch on that. Is it possible to highlight the paragraph or make overlay on the whole paragraph or change the color of that paragraph. Any Help please?
As your book page is an image, the only way you can do it is to either change the image or add a view on top with a color and an alpha value. With the latter you also overlay the letters of course, so the effect will kind of blurry your text.
Next to that, recognising the paragraph won't be trivial, depending on your image quality. The same counts for changing the image - if your background is not a clean color you have to introduce some threshold for which color is the background color and should be changed to the highlight color.
For how to change the color of specific pixels in an UIImage see here:
iPhone : How to change color of particular pixel of a UIImage?

Value for UITabelView background color on iPad

Need to make a matching graphic, does anyone know the color value of the iPad UITableView background color?
It is a gradient of different shades of gray, not a solid color.
But a close enough color is 0xdddddd.

Resources