peterfriese / What-is-new-in-SwiftUI

A list of everything new for SwiftUI after WWDC 2022.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What's New In SwiftUI for iOS Cheat Sheet - WWDC22

By Big Mountain Studio

A list of everything new in SwiftUI after WWDC 2022.

Working with Data

Environment Values

SwiftUI Views

New Controls

  • Guage - A view that shows a value within a range. This can be circular or straight.
  • MultiDatePicker - A control for picking multiple dates.
  • NavigationStack - A view that displays a root view and enables you to present additional views over the root view. To navigate, use a NavigationLink in combination with the navigationDestination modifier. You can also specify a NavigationPath to create or manage your stack of views.
  • NavigationSplitView - A container that presents 2 or 3 views in columns. (sidebar, content, detail)
  • RenameButton - A button that triggers a standard rename action. Used with the renameAction modifier.
  • ShareLink - A view that controls a sharing presentation.

Updated Controls

NavigationLink

  • Works in combination with the navigationDestination modifier. NavigationLinks have values and if there is a navigationDestination modifier that matches the NavigationLink's value type, then it is used and navigates to the view the navigationDestination specifies.

Stepper

  • You can provide a format parameter to handle conversions for number, percent, dateTime, iso8601 date format and now URL format.

Toggle

  • You can bind a Toggle to an array of values.

Accessibility Modifiers

Appearance Modifiers

  • backgroundStyle - Sets the specified style to render backgrounds within the view.
  • tint(ShapeStyle - Sets the tint within this view.
  • scrollDisabled - Disables or enables scrolling in scrollable views.
  • menuOrder - The preferred order of items for menus. (Fixed, Priority)
  • persistentSystemOverlays - Preferred visibility of the non-transient system views overlaying the app.
  • scrollIndicators(:axes:) - Sets the visibility of scroll indicators within this view.
  • widgetAccentable - Adds view and all subviews to the accented group.
  • widgetLabel - Returns a text label that displays additional content outside the accessory family widget’s main SwiftUI view.

Text and Symbol Modifiers

Many of the modifiers that were just for Text can now be applied to any view and all Text within will adopt the modifier.

Navigation Modifiers

Toolbar Modifiers

  • toolbar(:in:) - Specifies the visibility of a bar managed by SwiftUI. (Place it automatically, bottom, navigation bar, tab bar or window toolbar.)
  • toolbarBackground - Customize the background style.
  • toolbarColorScheme - Specifies the preferred color scheme (light or dark) of a bar.
  • toolbarRole - Configures the semantic role (automatic, browser, editor, navigationStack) for the content populating the toolbar.

Context Menu

Style Modifiers

Grid Modifiers

  • gridCellColumns - Tells a view that acts as a cell in a grid to span the specified number of rows.
  • gridCellAnchor - Custom alignment anchor for a view that acts as a grid cell. (top, topLeading, topTrailing, bottom, etc.)
  • gridCellUnsizedAxes - Asks grid layouts not to offer the view extra size in the specified axes (horizontal or vertical).
  • gridColumnAlignment - Overrides the default horizontal alignment of the grid column that the view appears in.

Input and Event Modifiers

  • SpatialTapGesture - A gesture that recognizes one or more taps and reports their location.
  • onTapGesture(count:coordinateSpace:perform:) - Adds a tap gesture within the specified coordinate space. The onTapGesture isn't new. But specifying the coordinate space is.
  • defersSystemGestures - Sets the screen edge from which you want your gesture to take precedence over the system gesture.
  • defaultFocus - Default focus is evaluated by assigning a value to a given focus state binding.

Searchable

There are over a dozen new searchable modifiers that can be used now. Rather than go through them all, I think it would be better to just list out some of the new parameters:

  • scope: A binding for the active scope of the search field.
  • scopes: A view builder representing the scopes of the search field which will be used to populate a Picker.
  • token: A view builder that creates a view given an element in tokens.
  • tokens: A collection of tokens to display and edit in the search field.
  • suggestedTokens: A collection of tokens to display as suggestions.
  • SearchSuggestionsPlacement - A structure that defines ways in which search suggestions may be placed. (automatic, content, menu)

Presentation Modifiers

State Modifiers

  • backgroundPreferenceValue - Reads the specified preference value from the view, using it to produce a second view that is applied as the background of the original view.
  • overlayPreferenceValue - Reads the specified preference value from the view, using it to produce a second view that is applied as an overlay to the original view.

Text Input & Output

TextField

The TextField can now overflow horizontally or vertically by specifying an axis.

TextEditor

  • findNavigator - Programmatically presents the find and replace interface for text editor views.
  • findDisabled - Prevents find and replace operations in a text editor.
  • replaceDisabled - Prevents replace operations in a text editor.

Font

Images

The Image initializer now has a new parameter called variableValue that the rendered image can use to customize its appearance. If the symbols does not support it, this has no effect.

  • ImageRenderer - An object that creates images from SwiftUI views. So you can compose a SwiftUI view and then generate an image or PDF from it.

Animations

  • contentTransition - Modifies the view to use a given transition as its method of animating changes to the contents of its views.

Charts

  • -

About

A list of everything new for SwiftUI after WWDC 2022.