0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UIColor から CIColor に変換するときの注意

Posted at

前提

UIColor から CIColor にする方法は2種類あります

# 変数 color は UIColor のインスタンスとする

# initializer
CIColor(color: color)

# property
color.ciColor

注意

color.ciColor で取得する時、 color が Core Image でイニシャライズされたものでない (= CIColor で作成されてない) 場合は例外を返されます。
公式ドキュメントにはかいてありますが、抜け穴だと思います。

This property throws an exception if the color object was not initialized with a Core Image color.

結論

基本的に CIColor(color:) の方を使っておけば問題ない。

環境

  • Swift 5

参考

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?