2015-04-12 89 views
1

我试图使UITextView背景色成为50%透明。我尝试将alpha设置为0.5,但它也将文本alpha更改为0.5,这不是我所需要的,我只需要视图为50%透明。很热使UITextView在Swift中使用50%透明色

+1

你尝试设置文本视图的背景颜色? – nhgrif

+0

如果要执行textView的Background Transparent请按照以下步骤操作:1.将UITextView的Background Color属性设置为ClearColor。 2.将UITextView的alpha设置为0.5。 –

回答

4

如果您只想让背景颜色具有透明度而不是文本,则可以将背景颜色设置为具有小于100%的Alpha值。

例如,在这里我们有一个白色背景上的蓝色背景的文本字段:

enter image description here

如果我选择文本视图的“属性检查器”,并朝下方滚动,我可以设置背景色:

enter image description here

如果我们选择纯红色,50%不透明,因为这样的:

enter image description here

现在看文本视图的外观与我们的50%的红色铺在蓝色的背景:

enter image description here