How do I create a transparent UITextField?
26,005
Solution 1
Objective-C
If you only want to make the background (rather than the whole UITextView) transparent, I believe you should be do this via the backgroundColor property it inherits from UIView.
As such...
[yourTextView setBackgroundColor:[UIColor clearColor]];
...should hopefully do the trick.
If however, you want to make the whole UITextView transparent, the alpha property @taskinoor mentions is perfect.
Solution 2
You can set the alpha of text view to any desired value.
myTextView.alpha = 0.5; // 50% transparent
Solution 3
I use in this way:
[textField setBackgroundColor:[UIColor clearColor]]; //clear background
[textField setBorderStyle:UITextBorderStyleNone]; //clear borders
Solution 4
Swift 4 and higher
For Swift 4 use this:
yourTextView.backgroundColor = UIColor.clear
Comments
-
good guy almost 4 years
On my 1)
UIView
one (2)UIImageView
will be on this (3)UITextView
.This
UITextView
must be Transparent and we have to view theimageView
.How can I do this?
-
John Parker over 13 yearsWon't the alpha property affect everything (text included)? Then again, perhaps that's what he wants. (Hard to tell from the question.)
-
taskinoor over 13 yearsYa, text also be changed. It guess that's what he is looking for. Otherwise I have misunderstood the question.
-
good guy over 13 yearshi Taskinoor i am looking for UITextView must be Transparent without effecting the Text on it,
-
taskinoor over 13 years@Nandakishore, try the answer of middaparka then. You can create UIColor with specific alpha value by using UIColor colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha method.