0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Swift】UILabelがダークモードで白くなる? `isEnabled = false` の落とし穴と対策

0
Posted at

iOSアプリ開発中、ダークモードでUILabelの文字が白く見える現象に遭遇しました。
実はこれ、isEnabled = false によるシステム自動色変換が原因です。
この記事では、原因と解決策をコード付きで解説します。


1. 背景

UITableViewCell内に置いているUILabelがダークモード設定だと白の背景色と同じ色になって何も見えない!
みたいなことがあったので原因と対策の共有です

2. 環境

  • Xcode26
  • iOS26
  • swift5

再現コード

let label = UILabel()
label.text = "無効化テキスト"
label.textColor = .black
label.backgroundColor = .white
label.isEnabled = false

3. 対策

UILabelの文字色を設定する!
シンプルですね

label.textColor = .black
0
0
1

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?