creating a gradient bar ios - ios

How would I create a gradient bar so that when I pan over it I could change the color?
I could easily add a UIPanGestureRecognizer and get some translation within a UIView, but how would I change the RGB values of a UIColor appropriately?

Instead of using an RGB colour, I would use HSB. Just change the hue depending on the swipe.
If you treat the top of the screen as 0.0 and the bottom as 1.0, as the user swipes their finger from top to bottom, the colour should go through it's full spectrum. Then
CGFloat percentTranslation = currentY / self.view.bounds.size.height;
[UIColor colorWithHue:percentTranslation saturation:1.0 brightness:1.0 alpha:1.0]

I've done this before. The easiest way without doubt is to create a png image and use that.
You can calculate the per pixel colour but it's far quicker to just use an image.
In fact. I created a full colour picker which you can see in my app https://itunes.apple.com/gb/app/game-of-life/id477039315?mt=8
The colour bar in the 2nd screen shot is just a png. And the colour square uses a transparent image that has a black-transparent gradient bottom to top and a white-transparent gradient left to right.
All I do is set the background colour of the image view when the colour is selected on the bar.

Related

Blurred or transparent bottom of image

I need to add some effect to background image that will blurring the image in the bottom. Like here on background image :
Does someone know how to do it ?
That's not actually blurred, it's fading out to white. You can achieve this by putting a vertical gradient over the top of the image that goes from 100% opaque (alpha 1.0) white at the bottom to 0% opaque (alpha 0.0) white at the top.
There's a decent gradients tutorial here:
http://blog.apoorvmote.com/gradient-background-uiview-ios-swift/
Create a UIView with required CGRect and then add your UIImageView as subview to the UIView. Now set some gradient color to UIView, this way you can achieve your requirement.

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?

Transparency through multiple views

I have an icon image that is ontop of a UIView with a black color. I would like to be able to see the bottom view within the outline of the icon image.
Guessing CALayer is the way to go, just not too sure how to use it
Useful information
-Splash Screen Background = gray
-Splash Screen Size = view.frame.size
-Icon image size = 75 x 75
Thanks
If you are using the UIImageView for icon then set its alpha less than 1 i.e. 0.8 or 0.5 as you want the transparency.
Otherwise user the transparent image.

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!

Remove Transparency From Glyph.Data in SpeedButtons

I have an old app (Delphi 5) which I want to give it some changes.
I have set a Glyph.Data for a speedbutton, but some colors are transparent and in some places I see small white dots on my image, I do not want to set transparency for the image, How to remove it (transparency)?
Any help is really appreciated.
Thanks :)
The transparency is a color that is not drawn.
You just have to change the image or set another color as the transparent one.
From Delphi 6 Help
Transparent color
Use the Transparent color drop-down to
specify which color is used to create
a mask for drawing the image
transparently. The default transparent
color is the color of the bitmap's
left-most pixel in the bottom line.
You can also change the transparent
color by clicking directly on a pixel
in the selected image.
When an image has a transparent color,
any pixels in the image of that color
are not rendered in that color, but
instead appear transparent, allowing
whatever is behind the image to show
through.
If the image is an icon, Transparent
color appears grayed and the
transparent color is set to clNone.
This is because icons are already
masked.
Set TSpeedButton.Transparent to False.
I have found the answer, Delphi thinks the transparent color is the color of most left - bottom pixel of this image. So If I set a color which is not used in my image in the most left-bottom of my image, then Delphi only will make that small pixel transparent and other parts of my image will be OK without transparency, So this post is completed by myself :))

Resources