Reputation: 4980
In my application, I have a large text field that allows the user to input notes, but the only issue is that it does not blend into the background image that I have set. With the UITextField, you can set the border in the Interface Builder so that it does not have a white background, it has a transparent background making it show the background I have set behind it. I did not see this Border option with the UITextView, does anyone know how I can achieve the same effect? (I'm using Xcode 4.2 by the way).
Thank you!
Upvotes: 0
Views: 2714
Reputation: 331
To set the background to be transparent on a UITextView you can use
UITextView* myTextView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,280,180)];
[myTextView setBackgroundColor:[UIColor clearColor]];
If you want to add a border to the UITextView then you would need to add that to the layer of the textView which you could do in the following way
[[myTextView layer] setCornerRadius:15.0f]; //You don't need to set this but it will give the view rounded corners.
[[myTextView layer] setBorderWidth:1.0f]; //again you pick the value 1 is quite a thin border
[[myTextView layer] setBorderColor:[[UIColor blackColor] CGColor]]; //again you can choose the color.
That should answer both your questions I think.
Upvotes: 2
Reputation: 11839
You can use following code-
#import <QuartzCore/QuartzCore.h>
....
textView.layer.borderWidth = 5.0f;
textView.layer.borderColor = [[UIColor grayColor] CGColor];
decide color and border width as per your need.
Upvotes: 3