Fade out image but not text on UILabel for iPhone - iphone

I have a label I have added a background to like this:
myLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"some image"]];
The user will enter text into the label and when finished, I would like to have the background image fade away but have the text remain. I've tried UIView Animations but UIImage does not inherit from UIView so that method has not worked and I am a bit stuck. Either I need to add a background image to my label differently or animate in a different way to get the fade out. Any thoughts would be appreciated.

Why not just use a UIView where you add both another UIView with your background, and a UILabel on top, like so?
UIView
UIView
UILabel (with [UIColor clearColor] as backgroundColor)
Then you can fade out the second UIView, and the UILabel will remain visible.as backgroundColor)

Related

Adding a background image to a UILabel

I'm attempting to add a UIImageView to the subview of a UILabel, but for some reason, I'm unable to have it as the background as this will cover the actual label text.
I don't want to set the UILabel's background color as because it will repeat as a pattern:
[self setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:#"someBg.png"]]];
Looking at the number of subviews to a raw UILabel it seems like the text isn't a UIView so adding the subview to index 0 won't help either.
I need the text to be ON TOP of the image background.
Any ideas?
Your options:
Wrap the label and the background image view in another container view.
Write your own label class that supports background images.
Anyhow I solved this by inheriting UITextField and adding the subview to that. This works since there's actually a UILabel subview within this control and adding it behind it naturally solves the problem.
Also, I disabled user interaction so that it behaves like a label.

Layering UIViews so that bottom most layer can be seen

I have a UIView to which i add a background image. Then to that view i add a scroll view. To the scroll view i add some UIButtons.
I would like to be able to set the scroll view to be transparent (still being able to see the UIButtons) so that i can see the background image underneath it, so that it shows between the buttons.
I have tried setting the scrollview background to [UIColor clearColor] but this doesnt work.
Thanks.
In addition to setting the backgroundColor to [UIColor clearColor], you also have to set
scrollView.opaque = NO;
Change the UIScrollView.alpha level to 0.0f

Moving the background image of iPhone upon event

I have a navigation based app where a certain pushed view has a nice background image. Now this view contains a UITextView which is transparent so my background shows all over the whole view except the top which holds the navigation bar. Now when I start editing the textview I would like the for the textview and the background image to "slide" up a few pixles under the navigation bar to be more visible when the keyboard shows up (without keyboard it is centered in on the screen).
I set the background with:
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"background.png"]];
self.view.backgroundColor = background;
[background release];
But this does not allow me to move it. So I guess I have to make a subview or something to get this to work. I already have the animation for the textview in place, it's just the background image I also would like to move. How can I make this happen?
Just use the UIImageView for the background...

Is there a way to fix the background image of a UITableView

I have set the background of my UITable with a custom image.
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
The problem I'm having is the background image is scrolling and doesn't look good at the top and bottom of the screen where you see the image being joined.
Is there a way to fix the position of the background image and just have the table scroll over the top of it?
Insert a UIImageView behind the UITableView. Set the UIImageView's image to background.png. Use [UIColor clearColor] as the table's background.
You need to put a UIImageView beneath your table view, set the table view's background color to clear (or in IB, set the opacity property of its background at 0). Then construct your CELL views to have clear areas that your background image can be seen through. You can do that programmatically or in IB (it's easier to visualize in IB, but the code to hook it all together is a bit tricky).

How to make UITextField and Round Rect Button transparent?

I have a view with a button and three UITextFields. The view's background is an image. I want UITextField's and Round Rect Button's backgrounds to be transparent, so the have their functions and display text, but there are no backgrounds. Adding a transparent image as a background doesn't help.
Thanks in advance!
As pheelicks said for UIButton can create it with type UIButtonTypeCustom.
For UITextField set its border style to UITextBorderStyleNone.
For the button you need to change the button type to:
button.buttonType = UIButtonTypeCustom;
See this question
As for the textfields, I don't think you can make them transparent. One solution would be to set the background image of each textfields to the image that would be showing through if the textfields were transparent. If you get it pixel perfect then it'll look as if the textfields are transparent
[[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(0, 0, 100, 100)];