17

On my 1) UIView one (2) UIImageView will be on this (3) UITextView.

This UITextView must be Transparent and we have to view the imageView.

How can I do this?

Jonas Deichelmann
  • 3,513
  • 1
  • 30
  • 45
good guy
  • 569
  • 5
  • 11
  • 25

5 Answers5

23

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.

Jonas Deichelmann
  • 3,513
  • 1
  • 30
  • 45
John Parker
  • 54,048
  • 11
  • 129
  • 129
9
  1. Go down to the utilities panel (on the right) and scroll down to the "View" section.
  2. Then, see the "Background" field. I already have my UITextField/UITextView transparent. Your's should have a solid color, right? That means that the object is not transparent. enter image description here
  3. Open the pop-up menu and press "Clear Color". Then, you must see the color to be half black and half white (like mine). That is how Xcode signifies transparency.

Then, you are done (you don't have to deal with any code if I understand you correctly)!

9

You can set the alpha of text view to any desired value.

myTextView.alpha = 0.5;    // 50% transparent
taskinoor
  • 45,586
  • 12
  • 116
  • 142
  • Won't the alpha property affect everything (text included)? Then again, perhaps that's what he wants. (Hard to tell from the question.) – John Parker Jan 05 '11 at 10:41
  • Ya, text also be changed. It guess that's what he is looking for. Otherwise I have misunderstood the question. – taskinoor Jan 05 '11 at 10:43
  • hi Taskinoor i am looking for UITextView must be Transparent without effecting the Text on it, – good guy Jan 05 '11 at 12:49
  • @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. – taskinoor Jan 05 '11 at 14:07
7

I use in this way:

[textField setBackgroundColor:[UIColor clearColor]]; //clear background
[textField setBorderStyle:UITextBorderStyleNone]; //clear borders
ademar111190
  • 14,215
  • 14
  • 85
  • 114
4

Swift 4 and higher

For Swift 4 use this:

yourTextView.backgroundColor = UIColor.clear
Jonas Deichelmann
  • 3,513
  • 1
  • 30
  • 45