LoginSignup
2
2

More than 3 years have passed since last update.

UIColorをCGColorで渡す時にalphaをいじる

Posted at

まくら

タイトルのまんまです。

CALayerを扱う時などにUIColorCGColorの変換がよく発生しますが、そんな時の小ネタです。

borderColorに透過した色を設定したい時とかに、一旦UIColorを変数に確保してalphaをいじっていたのですが、ワンライナーで書けたので備忘録。

ほんだい

self.layer.borderColor = UIColor.red.cgColor.copy(alpha: 0.8)

以上でござい。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2