26
19

More than 1 year has passed since last update.

SwiftUIに関する非推奨のmodifierとその代替を一覧にしてみた

Last updated at Posted at 2021-10-02

はじめに

SwiftUIもiOS13から登場して今年で3年目になります。
初期の頃から見るとかなり使いやすく、また意図しない動作も減ってきています。
またその過程で非推奨もどんどん増えてきていますので
2021.10.1時点での非推奨と代替の一覧を作ってみました。
また以下公式ドキュメントにもありますので詳細はこちらをご覧ください。

Deprecated Modifiers

一覧

非推奨 代替
colorScheme preferredColorScheme
listRowPlatterColor listItemTint
background(_:alignment:) background(alignment:content :)
overlay(_:alignment:) overlay(alignment:content:)
autocapitalization(_:) textInputAutocapitalization(_:)
navigationBarTitle navigationTitle
contextMenu(_:) contextMenu(menuItems:)
DoubleColumnNavigationViewStyle ColumnNavigationViewStyle
edgesIgnoringSafeArea ignoresSafeArea
accentColor tint
animation(_:) withAnimation(::) or animation(_:value:)
actionSheet confirmationDialog
alert(isPresented:content:) alert(_:isPresented:actions:message:)

補足

textInputAutocapitalization

Type Properties

.characters

すべての文字を大文字にする自動大文字化動作を定義します。

.never

大文字小文字の区別をしない自動大文字入力の動作を定義します。
(大文字小文字を自動的に変換せず、そのまま返します)

.sentences

すべての文の最初の文字を大文字にする自動大文字化動作を定義します。

.words

すべての単語の最初の文字を大文字にする自動大文字化動作を定義します。

その他

onCommit → onSubmit

感想

iOS15から本格的に使用できる状態になってきた印象です。
iOS13は本当に不安定です。
同じコードでもiOS14からの挙動とiOS13の挙動で違いがあるくらいなのでiOS13を切れるなら切る事をオススメします。笑

26
19
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
26
19