2012-01-03 85 views
0

在我的应用程序中,我有一个允许用户输入注释的大文本字段,但唯一的问题是它不会混合到我设置的背景图像中。使用UITextField,您可以在界面生成器中设置边框,使其没有白色背景,透明背景使其显示背后的背景。我没有看到这个与UITextView的边界选项,有谁知道我可以如何实现相同的效果? (顺便说一句,我使用Xcode 4.2)。UITextView问题

谢谢!

+0

'边框宽度'和'边框颜色'更好。 – 2012-03-30 07:17:25

回答

2

您可以在Interface Builder中更改背景的不透明度。

Text View with background

Select it and change the background colour

Slide the opacity slider to make the background transparent.

+0

+1抽空发布图片 – esqew 2012-01-03 18:01:16

+0

非常感谢您的帮助! – John 2012-01-03 18:13:31

+0

不是问题!很高兴我帮了忙! – 2012-01-03 18:21:05

2

要设置的背景是在一个UITextView透明的,你可以使用

UITextView* myTextView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,280,180)]; 
[myTextView setBackgroundColor:[UIColor clearColor]]; 

如果要添加边框的的UITextView然后你需要把它添加到你可以在后面做的textView层中ing的方式

[[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. 

这应该回答你的问题,我认为。

2

您可以使用下面的代码 -

#import <QuartzCore/QuartzCore.h> 

.... 


textView.layer.borderWidth = 5.0f; 
textView.layer.borderColor = [[UIColor grayColor] CGColor]; 

决定颜色和边框宽度根据自己的需要。