For a white & transparent UIView, make just the white darker - ios

Imagine you have Icon:UIView which is mainly transparent, but there is some pure white drawing or pixels (say an icon of a "arrow").
Icon sits on top of other material (a photo - whatever)
You want to class Darken:Icon
You want it so that in Darken, quite simply, the arrow is the same but a bit darker - a gray.
(And to be clear, the photo behind, the superview, is totally unaffected. All that changes is the white lines of the "arrow" become gray. The transparent parts of Icon are totally unaffected.)
Obviously you could do this by modifying the code in Icon (of just changing the PNG, if the case) but you don't want to, you want "Darken" to be able to darken any other UIView.
How to do?
I think it's done by adding a CALayer, but I am damned if I can figure out wtah the blend mode (or other issue) would be ..... how to?

Related

tab bar icons appear as blue squares

Well, the title says most of it. I've tried with icon sets of 75/50/25 px and 72/48/24 px, as stated by different guides, but when I run the app in Xcode, the icons appear as (appropriately sized) blue squares. The icons are all black and white .png files, with negative images for the selected images. Any suggestions would be appreciated.
This might not fix your issue, and also may seem very obvious. But I'll put it here just in case it helps anyone.
First of all, I'm going to point out scenarios to check that can get you in this state that may or may not apply to everyone:
The asset's render type is set to Template Image
You are changing the tabBar.tintColor
If either of these are true and you are getting a solid colored square as your icon, the first thing I would check is the actual image you are using. It is probably an image/icon sitting on a white background or something like that rather than a transparent background.
If you are using a .png, .pdf, or .svg icon and want to tint the icon, you will need a transparent background. Transparency doesn't exist for .jpegs so they just won't work for tinting the icons.
This is because changing the tint will tint the whole image. If there isn't transparency, Xcode will have no idea what is icon and what is background. So a 40x40 icon just becomes a colored square.
Another benefit of using a transparent background will be now instead of having multiple images for selected/unselected states, you can just set the desired colors for .selected and .normal states and use one image.
Okay, the solution is NOT to set the image to render as image, but to use an alpha 0 background instead of a white background on the icon image.
Another tip. Don't name your image assets the same name as iOS System icons/glyphs. I had a download icon labeled download(.png). After renaming the issue disappeared. Very inconsistent behavior.

GIMP: Setting entire foreground to a particular colour

In GIMP version 2.8, I have an image with a black foreground, and a transparent background. I want to set the entire foreground to red, instead of black. What's the simplest way of doing this?
I have tried using the fuzzy select tool and doing a bucket fill on the selection, but this doesn't seem to select the entire foreground. After the bucket fill, there is still a black line around the edge of the foreground image. So it seems that the fuzzy selector didn't select the entire foreground. On closer inspection, the edges of the foreground are not perfectly black, but have some grey pixels. But when using the fuzzy selection, I set a very high threshold (250), so I would have thought this this would select the entire foreground, including the grey pixels.
Any help? Thanks!
The gray pixels aren't grey, they are partially transparent black pixels. If you replace black, you want to keep that partial transparency because this is what gives smooth edges. And there is an easy solution:
Set the alpha-lock of the layer (this is the checkerboard icon at the top of the Layers list) (or in code: gimp-layer-set-lock-alpha)
Do not use selection.
Bucket-fill the layer with the required color. The alpha-lock will preserve the opacity of the pixels.

Stretch image border uniformly and leave center of image unstretched on iOS

Is it possible to achieve the same thing on iOS as on Android with this 9-patch file?
Result should be something like this. The flower is something on the background. Then I want to apply the gray overlay with transparent (see through, not stretched) logo in the center.
(the file is not a valid 9-patch, because of wider patch areas, but that is only for question clarity)
So basically I'd like to overlay the screen with this semi-transparent gray color and in the center would be unstretched logo - kind of cut-off from the overlay. (Notice that logo in image is completely transparent)
I tried to use image slices, but I can't define multiple slices per dimension, so just one border is resizing.
I'd like to avoid tile-ing the background from multiple views.

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?

make button glyph have a transparent background in delphi 7?

I have four TSpeedButton objects, each with a BMP file assigned as a glyph for the button image. For whatever reason, delphi has decided that two of the button images should have a transparent background and two should have a white background. I created the bitmaps myself, so they are all saved at the same color depth and are using pure white (not some shade of almost white) for the background and have background color in all four corner pixels of the image.
Why would some of the glyph images show up with a transparent background and some not? What is the criterion for making the background transparent? How can I make my button images all have transparent backgrounds instead of half of them having transparent backgrounds?
Ken's comment
Delphi's glyph handling uses the pixel in the lower-left corner to determine the transparent color. All pixels that match that color should be shown as transparent. Does the lower-left pixel color match in all of the glyphs, and does it match the areas you want to be transparent? (Without the images, it's hard to tell what the problem is, but I thought I'd post this as a potential for investigation.)
appeared to hold the correct answer (sorry, can't accept a comment as the right answer!). The image I was using had a shadow reaching to the lower left corner so it was almost white in that corner and exactly white in all the other corners.
I had a similar problem with D5 and I cludged a fix for this as I never found out why it was happening.
Define the image size one Row taller than the actual image/glyph is. This will force the image to be written starting at the top left and stop just before the last row. That will force the use of a non-transparent color and the extra row below the image is not visually noticeable.

Resources