views:

685

answers:

3

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!

+1  A: 

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

pheelicks
Thanks! The button worked!
Knodel
+2  A: 

As pheelicks said for UIButton can create it with type UIButtonTypeCustom.

For UITextField set its border style to UITextBorderStyleNone.

Vladimir
Thank you so much! It really worked!
Knodel
Hmm.. Another problem appeared. Is it possible to make a border around the button?
Knodel
See this question about adding border to UILabel: http://stackoverflow.com/questions/2311591/how-to-draw-border-around-a-uilabel I believe that approach should work for all UIView subclasses
Vladimir
Yep, it worked for the button, but it's rectangle. Any way to make it the same shape as default button?
Knodel
Sorry, already found this:button.layer.cornerRadius = 8;
Knodel
A: 

[[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(0, 0, 100, 100)];

TONy.W