user3616804
user3616804

Reputation: 13

UITextView Background Color

I am trying to get white text with a black background or transparent background for the UITextView in Xcode 5. There is no slider or setting for this in Xcode, must have been one in previous versions from what I can see in the questions here. but not anymore. I also have seen this

UItextView.backgroundColor = [UIColor clearColor];

as a way to fix it. But not sure where to put this as, if its even right. Thanks

Upvotes: 1

Views: 20056

Answers (4)

Jeff A. Ripke
Jeff A. Ripke

Reputation: 11

For swift:

@IBOutlet weak var textField: UITextField!
textField.backgroundColor = UIColor.clearColor()

Upvotes: -1

Joe Aspara
Joe Aspara

Reputation: 1197

Sure you can do it programmatically:

UITextView *txt = [[[UITextView alloc] initWithFrame: CGRectMake(10, 10, 100, 60)] autorelease];
[txt setBackgroundColor: [UIColor clearColor]];
[txt setTextColor: [UIColor whiteColor]];

but you can also accomplish this via the Attribute inspector of the graphic editor setting respectively the properties Color to 'White Color' and Background to 'Clear Color'.

This is the result with a custom background:

UITextView with alpha background and white color text

Upvotes: 8

iPatel
iPatel

Reputation: 47099

You should be write/set any property of your UITextView after initialization

_myTextViewName.backgroundColor = [UIColor clearColor]; // set clear backGround color or set as you want
_myTextViewName.textColor  = [UIColor whiteColor]; // set white text color or set as you want

Upvotes: 2

Erhan
Erhan

Reputation: 906

You can try this

UItextView *yourTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0 ,320, 50)];
yourTextView.backgroundColor = [UIColor clearColor];
yourTextView.textColor = [UIColor whiteColor];
[self.view addSubView:yourTextView];

Upvotes: 0

Related Questions