[英]How do I create a transparent UITextField?
在我的 1) UIView
一 (2) UIImageView
將在此 (3) UITextView
。
這個UITextView
必須是透明的,我們必須查看imageView
。
我該怎么做?
如果你只想使背景(而不是整個 UITextView)透明,我相信你應該通過它從 UIView 繼承的 backgroundColor 屬性來做到這一點。
如此...
[yourTextView setBackgroundColor:[UIColor clearColor]];
...應該有希望做到這一點。
但是,如果您想讓整個UITextView 透明,@taskinoor 提到的 alpha 屬性是完美的。
您可以將文本視圖的 alpha 設置為任何所需的值。
myTextView.alpha = 0.5; // 50% transparent
然后,您就完成了(如果我理解正確,您不必處理任何代碼)!
我是這樣使用的:
[textField setBackgroundColor:[UIColor clearColor]]; //clear background
[textField setBorderStyle:UITextBorderStyleNone]; //clear borders
Swift 4 及更高版本
對於 Swift 4 使用這個:
yourTextView.backgroundColor = UIColor.clear
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.