Making a background of a UIViewController less "alpha" - iphone

I have an image that I want to use as the background of my UIViewController. I can add it as a UIView. The point is that I want to add some transparency to it. I don't want the image to be as opaque as the original image, because it has some graphics on it and would be way too distracting. So I want to make it faded, sort of. I hope that makes sense.
Maybe I should subclass UIView? Can anyone show me the code to do something like this?

you can set alpha of the uiview from the xib else you can use [self.view setAlpha:0.5]

Related

UIImageview's reflection image

I have an imageview in my xib file. I have to create a reflection view in other UIimageview. So I have taken one UIimageview to place its reflection. it is around half of original image view.
Can anyone suggest me best way to do it. I have tried a lot of examples but not satisfied with any.
Any help would be appreciated.
You may use a CALayer to do this (it would be more efficient than having a separate UIImageView).
Create a CALayer, add the image to it, set its transform property to scale(1,-1), and finally set its maskLayer to a CAGradientLayer that will go from opaque to transparent.
You try this :
http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/88208-uiimage-reflection-tutorial.html

Views: How to overlay?

I want to use a UIProgressView but I want the background to be an image to make things a bit more good looking. I'm not sure how to lay one over the other. It would be important for the background image to encompass the UIProgressView.
Any help appreciated.
You can simply create a UIImageView for your background image, then add a UIProgressView as a sub view.
You can do this in either Interface Builder or in code such as [myBackgroundImageView addSubView:myProgressView];
Obviously you will need to setup the correct frame for both to ensure they are in the correct position.
Check out addSubview: in the Apple reference.

iPhone: Drawing on a UIButton

This tutorial shows how to draw on a graphics context for the view using Quartz 2D:
http://www.techotopia.com/index.php/An_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D
But I want to draw on a UIButton, not on a view. How can I do that?
Thanks
Draw on UIView . Add the view as subview to your UIButton.
A button IS a UIView. It inherits from UIControl, which inherits from UIView.
So buttons have a drawRect method.
So you can do everything described in the article you linked on a button.
However, buttons are set up to do a lot of things for you, and overriding the drawRect method could make those things not work correctly.
Buttons normally draw a title and a rounded rectangle frame. You can turn that off by setting the button's type to custom.
Custom buttons will draw an image if you install one.
Buttons normally also either draw a highlight over their image, or have a second image to use for the highlighted state. If you want to implement drawRect, you'll need to handle drawing the highlighted state yourself.
In general, you want to avoid using drawRect and use some other technique to get the content you want into your views.
What, exactly, are you trying to do?

Mask an UITextView / UIView

Is it generally possible with an UITextView to have a mask which I can animate at runtime? Imagine a flash light effect: You have a circle mask and then move this circle around -- and only whatever is in the circle is shown of the UITextView.
Sorry to be so general, but I was only wondering if this is generally possible with an UITextView and where I would need to start to achieve such an effect. I found this: Mask UIView and this Mask text inside UITextView but neither is really about animating a mask at runtime.
Thanks!
Yes this is completely possible and easy.
It is very likely you *do not need the difficult concept of masks, as explained in the links you mention.
All you have to do is make another UIView (just do it in IB), and then move that new UIView around as you see fit.
It's just that easy. Hope it helps.

Can I use DrawRect on a UIImageView loaded from a NIB?

I've created a NIB file with some button controls on it, and as a background it has an ImageView which contains a PNG file loaded from my project.
What I want to do is to draw on top of the ImageView - imagine that my UI is a clockface and I want to draw the hands of the clock on top of the background image.
Is it the correct approach to try to subclass the UIImageView and use its DrawRect as when I use the DrawRect of the default view I don't see anything on the screen?
I'm a little lost as I'm finding this particular bit of the documentation hard to follow.
Thanks.
Create a new custom UIView (e.g. named HandsView) that sits on top of your background view (by adding it as a subview of the UIImageView). In the custom view, you can use the drawRect method. Make sure, you clear the context to transparent, so that the background image can be seen below the HandsView.
If you just want to draw turning hands, you can also try to use two fixed UIImageViews with the images of the hands and use the transform property to apply a rotation.