Help us understand the problem. What is going on with this article?

[iOS] UIBarButtonItemの画像が青くなる件の対処方法

概要

Screen Shot 2019-01-31 at 16.50.38.png
上の図の星マークのように、UIBarButtonItem等で設置した画像が青で塗り潰されてしまう件の対処方法を書き留めておきます。

コード経由

UIImageをセットするタイミングでRenderingModeも同時に指定しておくことでオリジナルの状態で描画させることができます。

    func setImageWithRenderingMode(image: UIImage) {
        starButton.image = image.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
    }

Assets経由

Assets.xcassetsから該当の画像を選択し、右側のAttributes Inspectorを表示してRender Asの部分を"Original Image"に設定しておくことで、常にオリジナルの状態で表示させることも可能です。
ただし、この方法を適用した画像をタブのアイコン等に用いる場合、選択/非選択の状態で自動的に色を切り替えることができなくなるため注意が必要です。
Screen Shot 2019-01-31 at 16.58.02.png

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away