├── README.md └── _config.yml /README.md: -------------------------------------------------------------------------------- 1 | # What's New In SwiftUI for iOS Cheat Sheet - WWDC22 2 | ![new](https://user-images.githubusercontent.com/24855856/172445863-16ae2d0b-4617-416c-8619-5e1aca2f78b0.png) 3 | 4 | By [Big Mountain Studio](https://www.bigmountainstudio.com/) 5 | 6 | A list of everything new in SwiftUI after WWDC 2022. 7 | 8 | # Working with Data 9 | ## Environment Values 10 | * [accessibilityQuickActionsEnabled](https://developer.apple.com/documentation/swiftui/environmentvalues/accessibilityquickactionsenabled) - Shows quick action bar. 11 | * [renameAction](https://developer.apple.com/documentation/swiftui/environmentvalues/rename) - Activates standard rename action. 12 | * [menuOrder](https://developer.apple.com/documentation/swiftui/environmentvalues/menuorder) - The preferred order of items for menus. 13 | * [searchSuggestionsPlacement](https://developer.apple.com/documentation/swiftui/environmentvalues/searchsuggestionsplacement) - The current placement of search suggestions. 14 | * [isScrollEnabled](https://developer.apple.com/documentation/swiftui/environmentvalues/isscrollenabled) - Can or can't scroll. 15 | * [horizontalScrollIndicatorVisibility](https://developer.apple.com/documentation/swiftui/environmentvalues/horizontalscrollindicatorvisibility) - Can or can't see horizontal scroll indicators. 16 | * [verticalScrollIndicatorVisibility](https://developer.apple.com/documentation/swiftui/environmentvalues/verticalscrollindicatorvisibility) - Can or can't see vertical scroll indicators. 17 | * [scrollDismissesKeyboardMode](https://developer.apple.com/documentation/swiftui/environmentvalues/scrolldismisseskeyboardmode) - Dismiss keyboard when scrolling, never, automatically based on context or allow user to choose. 18 | * [supportsMultipleWindows](https://developer.apple.com/documentation/swiftui/environmentvalues/supportsmultiplewindows) - Check if platform allows multiple windows. 19 | * [displayStoreKitMessage](https://developer.apple.com/documentation/swiftui/environmentvalues/displaystorekitmessage) - Tells StoreKit to display an App Store message 20 | * [requestReview](https://developer.apple.com/documentation/swiftui/environmentvalues/requestreview) - Ask user to review your app. 21 | * [autocorrectionDisabled](https://developer.apple.com/documentation/swiftui/environmentvalues/autocorrectiondisabled) - Allow auto-correct or not. 22 | * [backgroundStyle](https://developer.apple.com/documentation/swiftui/environmentvalues/backgroundstyle) - Overrides the default system background style. 23 | * [contentTransition](https://developer.apple.com/documentation/swiftui/environmentvalues/contenttransition) - Method of animating the contents of views. 24 | * [contentTransitionAddsDrawingGroup](https://developer.apple.com/documentation/swiftui/environmentvalues/contenttransitionaddsdrawinggroup) - Transition with GPU-acceleration or not. 25 | * [showsWidgetLabel](https://developer.apple.com/documentation/swiftui/environmentvalues/showswidgetlabel) - Tells you if you can or can't display an accessory label. 26 | 27 | # SwiftUI Views 28 | ## New Controls 29 | * [AnyLayout](https://developer.apple.com/documentation/swiftui/anylayout/) - A view that can represent a container view such as a VStack, HStack, grids, etc. 30 | * [Chart](https://developer.apple.com/documentation/Charts/Chart) - A SwiftUI view that displays a chart. 31 | * [Gauge](https://developer.apple.com/documentation/swiftui/gauge) - A view that shows a value within a range. This can be circular or straight. 32 | * [Grid](https://developer.apple.com/documentation/swiftui/grid) - A container view that arranges other views in a two dimensional layout with the use of the [GridRow](https://developer.apple.com/documentation/swiftui/gridrow). 33 | * [LabeledContent](https://developer.apple.com/documentation/swiftui/labeledcontent/) - A container for attaching a label to a value-bearing view. This way it can layout appropriately depending on where it's used. For example, if in a Form, the label will be leading and the content portion will be trailing and gray. 34 | * [Layout Protocol](https://developer.apple.com/documentation/swiftui/layout) - A new protocol that you can conform to so you can create your own custom layout container control. 35 | * [MultiDatePicker](https://developer.apple.com/documentation/swiftui/multidatepicker) - A control for picking multiple dates. 36 | * [NavigationStack](https://developer.apple.com/documentation/swiftui/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](https://developer.apple.com/documentation/swiftui/view/navigationdestination(for:destination:)) modifier. You can also specify a [NavigationPath](https://developer.apple.com/documentation/swiftui/navigationpath) to create or manage your stack of views. 37 | * [NavigationSplitView](https://developer.apple.com/documentation/swiftui/navigationsplitview) - A container that presents 2 or 3 views in columns. (sidebar, content, detail) 38 | * [PhotosPicker](https://developer.apple.com/documentation/photokit/photospicker/) - A view that displays a Photos picker for choosing assets from the photo library. A selected photo is represented by a [PhotosPickerItem](https://developer.apple.com/documentation/photokit/photospickeritem). 39 | * [RenameButton](https://developer.apple.com/documentation/swiftui/renamebutton) - A button that triggers a standard rename action. Used with the renameAction modifier. 40 | * [ShareLink](https://developer.apple.com/documentation/swiftui/sharelink) - A view that controls a sharing presentation. 41 | * [Table](https://developer.apple.com/documentation/swiftui/table) - A container that presents rows of data arranged in one or more columns, optionally providing the ability to select one or more members, sort data, and style it. 42 | * [ViewThatFits](https://developer.apple.com/documentation/swiftui/viewthatfits) - A container view that adapts to the available space by providing the first child view that fits. 43 | 44 | 45 | ## Updated Controls 46 | ### Color 47 | * Has a new fixed [gradient](https://developer.apple.com/documentation/swiftui/color/gradient/) modifier that seems to lighten the color at the top in a linear gradient. 48 | * You can apply a [shadow](https://developer.apple.com/documentation/swiftui/shadowstyle) directly to a color too. 49 | * Shadows can now be [drop](https://developer.apple.com/documentation/swiftui/shadowstyle/drop(color:radius:x:y:)) or [inner](https://developer.apple.com/documentation/swiftui/shadowstyle/inner(color:radius:x:y:)) shadows. 50 | 51 | ### NavigationLink 52 | * You can still use a basic NavigationLink with a string and destination. `(NavigationLink("Go here") { Text("Here") }` 53 | * Also works in combination with the [navigationDestination](https://developer.apple.com/documentation/swiftui/view/navigationdestination(for:destination:)) 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. 54 | 55 | ### Stepper 56 | * You can provide a [format](https://developer.apple.com/documentation/foundation/parseableformatstyle) parameter to handle conversions for number, percent, dateTime, iso8601 date format and now URL format. 57 | 58 | ### Toggle 59 | * You can bind a [Toggle](https://developer.apple.com/documentation/swiftui/toggle/init(sources:ison:label:)) to a collection of values. 60 | * Multiple Text views within will be arranged hierarchically. (Second line less prominent than first line.) 61 | 62 | 63 | ## Accessibility Modifiers 64 | * [accessibilityActions](https://developer.apple.com/documentation/swiftui/view/accessibilityactions(_:)) - Adds multiple accessibility actions to the view. 65 | * [accessibilityQuickAction](https://developer.apple.com/documentation/swiftui/view/accessibilityquickaction(style:content:)) - Adds a quick action to be shown by the system when active. 66 | * [AccessibilityQuickActionStyle](https://developer.apple.com/documentation/swiftui/accessibilityquickactionstyle) - Presentation style of an accessibility quick action. (Outline, Prompt) 67 | 68 | ## Appearance Modifiers 69 | * [backgroundStyle](https://developer.apple.com/documentation/swiftui/view/backgroundstyle(_:)) - Sets the specified style to render backgrounds within the view. 70 | * [tint(ShapeStyle)](https://developer.apple.com/documentation/swiftui/view/tint(_:)-93mfq) - Sets the tint within this view using a ShapeStyle (which can be a color, gradient, blur, etc). 71 | * [scrollDisabled](https://developer.apple.com/documentation/swiftui/view/scrolldisabled(_:)) - Disables or enables scrolling in scrollable views. 72 | * [menuOrder](https://developer.apple.com/documentation/swiftui/view/menuorder(_:)) - The preferred order of items for menus. (Fixed, Priority) 73 | * [persistentSystemOverlays](https://developer.apple.com/documentation/swiftui/view/persistentsystemoverlays(_:)) - Preferred visibility of the non-transient system views overlaying the app. 74 | * [scrollIndicators(:axes:)](https://developer.apple.com/documentation/swiftui/view/scrollindicators(_:axes:)) - Sets the visibility of scroll indicators within this view. 75 | * [widgetAccentable](https://developer.apple.com/documentation/swiftui/view/widgetaccentable(_:)) - Adds view and all subviews to the accented group. 76 | * [widgetLabel](https://developer.apple.com/documentation/swiftui/view/widgetlabel(_:)-7wguh) - Returns a text label that displays additional content outside the accessory family widget’s main SwiftUI view. 77 | 78 | ## Text and Symbol Modifiers 79 | Many of the modifiers that were just for Text can now be applied to any view and all Text within will adopt the modifier. 80 | 81 | * [bold(isActive:)](https://developer.apple.com/documentation/swiftui/view/bold(_:)) - Applies bold to views when isActive is true. 82 | * [fontWeight](https://developer.apple.com/documentation/swiftui/view/fontweight(_:)) - Can now be applied to views (not just Text). 83 | * [italic(isActive:)](https://developer.apple.com/documentation/swiftui/view/italic(_:)) - Applies italics to views when isActive is true. 84 | * [strikethrough(:pattern:color:)](https://developer.apple.com/documentation/swiftui/view/strikethrough(_:pattern:color:)) - Can now be applied to views (not just Text). 85 | * [underline(:pattern:color:)](https://developer.apple.com/documentation/swiftui/view/underline(_:pattern:color:)) - Can now be applied to views (not just Text). 86 | * [baselineOffset](https://developer.apple.com/documentation/swiftui/view/baselineoffset(_:)) - Vertical offset that can now be applied to views (not just Text). 87 | * [kerning](https://developer.apple.com/documentation/swiftui/view/kerning(_:)) - Spacing between characters that can now be applied to views (not just Text). 88 | * [tracking](https://developer.apple.com/documentation/swiftui/view/tracking(_:)) - Spacing between all characters that can now be applied to views (not just Text). 89 | * [lineLimit](https://developer.apple.com/documentation/swiftui/view/linelimit(_:)-7ufty) - Line limit can now be applied to Text AND a vertical TextField. 90 | * [autocorrectionDisabled](https://developer.apple.com/documentation/swiftui/view/autocorrectiondisabled(_:)) - Used to be disableAutoCorrection on TextField. Can be applied to any view now. 91 | * [scrollDismissesKeyboard](https://developer.apple.com/documentation/swiftui/view/scrolldismisseskeyboard(_:)) - Dismiss keyboard when scrolling, never, automatically based on context or allow user to choose. 92 | * [findNavigator(isPresented:)](https://developer.apple.com/documentation/swiftui/view/findnavigator(ispresented:)) - Presents the find and replace interface for TextEditor views. 93 | * [findDisabled](https://developer.apple.com/documentation/swiftui/view/finddisabled(_:)) - Prevents find and replace operations in a TextEditor. 94 | * [replaceDisabled](https://developer.apple.com/documentation/swiftui/view/replacedisabled(_:)) - Prevents replace operations in a TextEditor. 95 | 96 | ## Navigation Modifiers 97 | * [navigationTitle(title:Binding)](https://developer.apple.com/documentation/swiftui/view/navigationtitle(_:)-7onr8) - Allows navigation title editing. 98 | * [navigationDocument](https://developer.apple.com/documentation/swiftui/view/navigationdocument(_:)-66zro) - Configures the view’s document for purposes of navigaiton. 99 | * [navigationDestination](https://developer.apple.com/documentation/swiftui/view/navigationdestination(for:destination:)) - Associates a destination view with a presented data type for use within a navigation stack. 100 | 101 | ## Toolbar Modifiers 102 | * [toolbar(:for:)](https://developer.apple.com/documentation/swiftui/view/toolbar(_:for:)) - Specifies the visibility of a bar managed by SwiftUI. (Place it automatically, bottom, navigation bar, tab bar or window toolbar.) 103 | * [toolbarBackground](https://developer.apple.com/documentation/charts/chart/toolbarbackground(_:for:)) - Specify the visibility of the background for the specified bar. 104 | * [toolbarColorScheme](https://developer.apple.com/documentation/charts/chart/toolbarcolorscheme(_:for:)) - Specifies the preferred color scheme (light or dark) for the specified bar. 105 | * [toolbarRole](https://developer.apple.com/documentation/swiftui/view/toolbarrole(_:)) - Configures the semantic role (automatic, browser, editor, navigationStack) for the content populating the toolbar. 106 | 107 | ## Context Menu 108 | * [contextMenu(menuItems:preview:)](https://developer.apple.com/documentation/swiftui/view/contextmenu(menuitems:preview:)) - Adds a context menu with a preview to a view. 109 | 110 | ## Style Modifiers 111 | * [gaugeStyle](https://developer.apple.com/documentation/swiftui/view/gaugestyle(_:)) - Sets the style for gauges within this view. (New for iOS) 112 | * [tableStyle](https://developer.apple.com/documentation/swiftui/view/tablestyle(_:)) - Sets the style for tables within this view. (New for iOS) 113 | * [disclosureGroupStyle](https://developer.apple.com/documentation/swiftui/view/disclosuregroupstyle(_:)) - Sets the style for disclosure groups within this view. 114 | * [navigationSplitViewStyle](https://developer.apple.com/documentation/swiftui/view/navigationsplitviewstyle(_:)) - Sets the style for navigation split views within this view. 115 | 116 | ## Grid Modifiers 117 | * [gridCellColumns](https://developer.apple.com/documentation/swiftui/view/gridcellcolumns(_:)) - Tells a view that acts as a cell in a grid to span the specified number of rows. 118 | * [gridCellAnchor](https://developer.apple.com/documentation/swiftui/view/gridcellanchor(_:)) - Custom alignment anchor for a view that acts as a grid cell. (top, topLeading, topTrailing, bottom, etc.) 119 | * [gridCellUnsizedAxes](https://developer.apple.com/documentation/swiftui/view/gridcellunsizedaxes(_:)) - Asks grid layouts not to offer the view extra size in the specified axes (horizontal or vertical). 120 | * [gridColumnAlignment](https://developer.apple.com/documentation/swiftui/view/gridcolumnalignment(_:)) - Overrides the default horizontal alignment of the grid column that the view appears in. 121 | 122 | ## Input and Event Modifiers 123 | * [SpatialTapGesture](https://developer.apple.com/documentation/swiftui/spatialtapgesture) - A gesture that recognizes one or more taps and reports their location. 124 | * [onTapGesture(count:coordinateSpace:perform:)](https://developer.apple.com/documentation/swiftui/view/ontapgesture(count:coordinatespace:perform:)) - Adds a tap gesture within the specified coordinate space. The onTapGesture isn't new. But specifying the coordinate space is. 125 | * [defersSystemGestures](https://developer.apple.com/documentation/swiftui/view/deferssystemgestures(on:)) - Sets the screen edge from which you want your gesture to take precedence over the system gesture. 126 | * [defaultFocus](https://developer.apple.com/documentation/swiftui/view/defaultfocus(_:_:priority:)) - Default focus is evaluated by assigning a value to a given focus state binding. 127 | 128 | ## Searchable 129 | There are over a dozen new [searchable initializers](https://developer.apple.com/documentation/swiftui/capsule/searchable(text:scope:placement:prompt:scopes:)-58flg) 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: 130 | * **scope**: A binding for the active scope of the search field. 131 | * **scopes**: A view builder representing the scopes of the search field which will be used to populate a Picker. 132 | * **token**: A view builder that creates a view given an element in tokens. 133 | * **tokens**: A collection of tokens to display and edit in the search field. 134 | * **[suggestedTokens](https://developer.apple.com/documentation/swiftui/capsule/searchable(text:tokens:suggestedtokens:placement:prompt:token:)-6b62c/)**: A collection of tokens to display as suggestions. 135 | 136 | [SearchSuggestionsPlacement](https://developer.apple.com/documentation/swiftui/environmentvalues/searchsuggestionsplacement) - A structure that defines ways in which search suggestions may be placed. (automatic, content, menu) 137 | 138 | ## Presentation Modifiers 139 | * [presentationDetents](https://developer.apple.com/documentation/swiftui/view/presentationdetents(_:)) - Sets the available detents for the enclosing sheet. (medium, large, custom, fraction, height) 140 | * [presentationDragIndicator](https://developer.apple.com/documentation/swiftui/view/presentationdragindicator(_:)) - Sets the visibility of the drag indicator on top of a sheet. 141 | * [offerCodeRedemption](https://developer.apple.com/documentation/swiftui/view/offercoderedemption(ispresented:oncompletion:)) - Sheet that enables users to redeem subscription offer codes. 142 | 143 | ## State Modifiers 144 | * [backgroundPreferenceValue](https://developer.apple.com/documentation/swiftui/view/backgroundpreferencevalue(_:alignment:_:)) - 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. 145 | * [overlayPreferenceValue](https://developer.apple.com/documentation/swiftui/view/overlaypreferencevalue(_:alignment:_:)) - 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. 146 | 147 | ## Text Input & Output 148 | ### TextField 149 | * The TextField can now overflow horizontally or vertically by specifying an [axis](https://developer.apple.com/documentation/swiftui/textfield/init(_:text:axis:)-7n1bm). 150 | * A [lineLimit](https://developer.apple.com/documentation/swiftui/ellipse/linelimit(_:)-1hy18/) modifier with one or a range of values can be added to specify how much the TextField can grow. Beyond that a scroll indicator will appear. 151 | ### TextEditor 152 | * [findNavigator](https://developer.apple.com/documentation/swiftui/view/findnavigator(ispresented:)) - Programmatically presents the find and replace interface for text editor views. 153 | * [findDisabled](https://developer.apple.com/documentation/swiftui/view/finddisabled(_:)) - Prevents find and replace operations in a text editor. 154 | * [replaceDisabled](https://developer.apple.com/documentation/swiftui/view/replacedisabled(_:)) - Prevents replace operations in a text editor. 155 | 156 | ### Font 157 | * [system(size:weight:design:)](https://developer.apple.com/documentation/swiftui/font/system(size:weight:design:)-697b2) - While the signature looks the same, the weight and design are now optional instead of required. 158 | 159 | ## Images 160 | The Image initializer now has a new parameter called [variableValue](https://developer.apple.com/documentation/swiftui/image/init(_:variablevalue:bundle:)) that the rendered image can use to customize its appearance. If the symbols does not support it, this has no effect. 161 | * [ImageRenderer](https://developer.apple.com/documentation/swiftui/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. 162 | 163 | # Animations 164 | * [contentTransition](https://developer.apple.com/documentation/swiftui/view/contenttransition(_:)) - Modifies the view to use a given transition as its method of animating changes to the contents of its views. 165 | 166 | # Charts 167 | * [Chart](https://developer.apple.com/documentation/Charts/Chart) - A SwiftUI view that displays a chart. You can customize many parts of the chart: 168 | * Background 169 | * Foreground 170 | * Style such as bar, point, area, rule, rectangle or line charts 171 | * Plot area 172 | * Legends 173 | * Overlays 174 | * Visibility of the X or Y axis 175 | * Scale of the X or Y axis 176 | * Scale and size of symbols used 177 | 178 | 179 | ![Gold logo](https://user-images.githubusercontent.com/24855856/173091471-81c1c475-fc64-4cb0-8149-343719a1cb12.png) 180 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman --------------------------------------------------------------------------------