Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

SwiftUI Essentials

48

Flashcards

0/48

Still learning
StarStarStarStar

LazyVGrid

StarStarStarStar

LazyVGrid arranges children in a grid that lazy-loads vertically. Syntax: LazyVGrid(columns: gridItems) { /* views */ }. Use for memory-efficient grids with many items.

StarStarStarStar

HStack

StarStarStarStar

An HStack arranges views horizontally. Syntax: HStack { /* views */ }. Used for creating horizontal layouts.

StarStarStarStar

Binding

StarStarStarStar

A @Binding property wrapper denotes a two-way connection to a state that is owned by another view. Syntax: @Binding var name: Type. Allows a parent to share state with a child view.

StarStarStarStar

TextField

StarStarStarStar

A TextField allows for user text input. Syntax: TextField("Placeholder", text: variable).Bindingenablesdynamictextupdates.variable). Binding enables dynamic text updates.

StarStarStarStar

Animation

StarStarStarStar

Animation adds animated transitions to view changes. Syntax: .animation(Animation.linear(duration: TimeInterval)). Used to make the UI more engaging.

StarStarStarStar

Environment

StarStarStarStar

Environment allows access to system-wide information within a view. Syntax: @Environment(\.presentationMode) var presentationMode. Use cautiously, as it couples view with environment data.

StarStarStarStar

EnvironmentObject

StarStarStarStar

An @EnvironmentObject is a property wrapper for accessing an observable object shared across a view hierarchy. Syntax: @EnvironmentObject var object: ObservableObjectType. Useful for injecting instances down the view hierarchy.

StarStarStarStar

Button

StarStarStarStar

Button triggers an action when pressed. Syntax: Button(action: { /* perform action */ }) { /* label view */ }. Can be used for user interactions.

StarStarStarStar

ScrollView

StarStarStarStar

ScrollView provides a scrollable view. Syntax: ScrollView { /* content */ }. Enables browsing content that exceeds the screen limits.

StarStarStarStar

Form

StarStarStarStar

Form groups user-input controls for data collection. Syntax: Form { /* form fields */ }. Generally used as a container for settings.

StarStarStarStar

ViewModifier

StarStarStarStar

ViewModifier protocol customizes the rendering and behavior of a view. Syntax: struct MyModifier: ViewModifier {}. Use to create reusable modifier effects.

StarStarStarStar

Safe Area

StarStarStarStar

Safe Area ensures content is within the visible area. Syntax: .edgesIgnoringSafeArea(.all). Use this to extend the view behind notches, status bars, or tab bars.

StarStarStarStar

Image

StarStarStarStar

Image displays images in the UI. Syntax: Image("imageName"). It's utilized for static and dynamic images.

StarStarStarStar

Sheet

StarStarStarStar

Sheet presents a modal view. Syntax: .sheet(isPresented: variable)/modalcontent/.Usedfortransienttasksorgatheringinputfromtheuser.variable) { /* modal content */ }. Used for transient tasks or gathering input from the user.

StarStarStarStar

ProgressView

StarStarStarStar

ProgressView displays the progress of a task. Syntax: ProgressView(value: progress, total: totalValue). Can be styled as a bar or a spinner.

StarStarStarStar

PreferenceKey

StarStarStarStar

PreferenceKey protocol defines how to store and retrieve view preferences. Syntax: struct MyPreferenceKey: PreferenceKey {}. Modifies the view's rendering pass for sharing data.

StarStarStarStar

Canvas

StarStarStarStar

Canvas provides a space for immediate-mode drawing using a GraphicsContext. Syntax: Canvas { context, size in /* drawing code */ }. Good for complex and custom graphics.

StarStarStarStar

VStack

StarStarStarStar

A VStack arranges views vertically. Syntax: VStack { /* views */ }. Used for creating vertical layouts.

StarStarStarStar

Picker

StarStarStarStar

Picker allows users to select from a set of options. Syntax: Picker("Label", selection: variable)/options/.Supportscustomizablepresentationstyles.variable) { /* options */ }. Supports customizable presentation styles.

StarStarStarStar

DatePicker

StarStarStarStar

DatePicker allows users to pick a date and time. Syntax: DatePicker("Label", selection: date).Canrestrictdatesandintegratewithdifferentcalendars.date). Can restrict dates and integrate with different calendars.

StarStarStarStar

ForEach

StarStarStarStar

ForEach is used to create views dynamically from a collection. Syntax: ForEach(collection) { item in /* view using item */ }. It can iterate over a constant range or dynamic data.

StarStarStarStar

LazyHStack

StarStarStarStar

LazyHStack creates a horizontally stacked view that only renders visible children. Syntax: LazyHStack { /* views */ }. Optimizes performance for horizontal lists with many items.

StarStarStarStar

Padding

StarStarStarStar

Padding adds space around the view content. Syntax: .padding(.all, 8). Applies space within the view boundary to avoid content clipping.

StarStarStarStar

Toggle

StarStarStarStar

Toggle is a switch that toggles a Boolean state. Syntax: Toggle("Description", isOn: variable).Oftenusedinsettingsinterfaces.variable). Often used in settings interfaces.

StarStarStarStar

Section

StarStarStarStar

Section groups views within containers like Lists and Forms. Syntax: Section(header: Text("Title")) { /* content */ }. Use to semantically group items.

StarStarStarStar

GeometryReader

StarStarStarStar

GeometryReader provides size and coordinate information. Syntax: GeometryReader { geometry in /* use geometry.size, geometry.frame(in:) */ }. Allows for creating size-dependent or responsive layouts.

StarStarStarStar

Slider

StarStarStarStar

Slider allows users to select a numeric value from a range. Syntax: Slider(value: variable,in:range).Usedoftenforsettingsorcontrols.variable, in: range). Used often for settings or controls.

StarStarStarStar

ObservedObject

StarStarStarStar

An @ObservedObject is a property wrapper that subscribes to an observable object for changes. Syntax: @ObservedObject var object: ObservableObjectType. Ideal for complex, sharable state management.

StarStarStarStar

List

StarStarStarStar

A List displays a scrolling, single-column list of rows. Syntax: List(/* items */) { /* row content */ }. Used for creating table-like structures.

StarStarStarStar

Transition

StarStarStarStar

Transition defines how a view enters or exits the screen. Syntax: .transition(.opacity). Enhances the user experience during view changes.

StarStarStarStar

Text

StarStarStarStar

Text displays read-only text. Syntax: Text("String"). It's used for static text in the UI.

StarStarStarStar

Alert

StarStarStarStar

Alert presents an alert dialog to the user. Syntax: .alert(isPresented: variable)Alert(title:Text("Title")).Utilizedforcommunicatinginformationorcapturingdecisions.variable) { Alert(title: Text("Title")) }. Utilized for communicating information or capturing decisions.

StarStarStarStar

ColorPicker

StarStarStarStar

ColorPicker lets users choose a color. Syntax: ColorPicker("Label", selection: color).Oftenusedinsettingsordrawingapps.color). Often used in settings or drawing apps.

StarStarStarStar

LazyVStack

StarStarStarStar

LazyVStack creates a vertically stacked view that only renders visible children. Syntax: LazyVStack { /* views */ }. Improves performance when dealing with many child views.

StarStarStarStar

Group

StarStarStarStar

Group groups multiple views without changing the UI layout. Syntax: Group { /* views */ }. Use to conditionally include views or to avoid view nesting limits.

StarStarStarStar

State

StarStarStarStar

A @State property wrapper is used to declare a source of truth for value types. Syntax: @State private var name: Type. Enables data-driven updates to the UI.

StarStarStarStar

Alignment

StarStarStarStar

Alignment defines how views align within their parent. Syntax: VStack(alignment: .leading) {}. Commonly used within Stacks to align child views.

StarStarStarStar

Shape

StarStarStarStar

Shape protocol defines a path that can be drawn. Syntax: struct MyShape: Shape {}. Used to create and customize geometric shapes.

StarStarStarStar

Aspect Ratio

StarStarStarStar

Aspect Ratio constrains a view's aspect ratio. Syntax: .aspectRatio(contentMode: .fit). Utilized to maintain the proportions of images or custom views.

StarStarStarStar

TabView

StarStarStarStar

TabView facilitates the creation of a tab-based interface. Syntax: TabView { /* tabs content */ }. Each tab can contain its own view hierarchy.

StarStarStarStar

Spacer

StarStarStarStar

Spacer creates flexible spaces between views. Syntax: Spacer(). It's often used to push views apart.

StarStarStarStar

NavigationView

StarStarStarStar

A NavigationView creates a navigation interface. Syntax: NavigationView { /* content */ }. Typically used to manage hierarchical content navigation.

StarStarStarStar

NavigationViewLink

StarStarStarStar

NavigationViewLink is used to create transitions between views in a NavigationView. Syntax: NavigationLink(destination: { /* Destination View */ }) { /* Label View */ }. Supports passing data to the destination view.

StarStarStarStar

Divider

StarStarStarStar

Divider draws a line to divide content visually. Syntax: Divider(). It is used to group or separate UI elements.

StarStarStarStar

LazyHGrid

StarStarStarStar

LazyHGrid arranges children in a grid that lazy-loads horizontally. Syntax: LazyHGrid(rows: gridItems) { /* views */ }. Suited for horizontal grids with many scrollable items.

StarStarStarStar

GridItem

StarStarStarStar

GridItem describes the size and spacing for items in LazyVGrid and LazyHGrid. Syntax: GridItem(.flexible(minimum: size)). Specifies layout properties for grid-based layouts.

StarStarStarStar

ZStack

StarStarStarStar

A ZStack overlays views on top of each other. Syntax: ZStack { /* views */ }. Used for creating overlapping content.

StarStarStarStar

Gesture

StarStarStarStar

Gesture allows for the implementation of custom gestures. Syntax: .gesture(DragGesture()). Use to detect and respond to touch events.

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.