テキストフィールドを含むアプリケーションがあります。
コードでこのテキストフィールドの背景の透明度を変更する方法はありますか?
はい、できます。
アルファを設定することで透明度を設定できます。あなたはデジタルカラーメーター(Macに組み込まれたアプリケーション)でカラーコードを写真に撮ることができます。
アルファ1を設定すると、透明度はなくなります。必要に応じて透明度を設定します(アルファを1未満に設定します)。
これを試して:
textfield.backgroundColor=[[UIColor colorWithRed:208.0/255.0 green:15.0/255.0 blue:202.0/255.0 alpha:0.6] CGColor];
白い背景に次のコードを入力するだけです
[yourTextField setBackgroundColor:[UIColor whiteColor]];
または、色をクリアしたい場合は、以下のコード
[yourTextField setBackgroundColor:[UIColor clearColor]];
とても簡単
:)
カスタム UITextFieldを使用する
UITextField *yourTextField= [[UITextField alloc] initWithFrame:frame];
yourTextField.borderStyle = UITextBorderStyleNone;
[yourTextField setBackgroundColor:[UIColor clearColor]];