SwiftUI_visionOS_Note

SwiftUI_visionOS_Note

Anything I learnt today about building visionOS app
ToDo List
2024-05-15

ToDo List

.onSubmit
2024-05-09

.onSubmit

As of iOS 15, we can use the new .submitLabel modifier to change the color and text of the submit button on the keyboard. Even more importantly, we can also use .onSubmit to run custom functions when users click on the submit button! These features

NavigationStack
2024-05-09

NavigationStack

NavigationLink , It only move up and back on stack only When it’s under NavigationStack, it can moves up and down freely.Text will show screen # and when the view is initialized, it will print the which screen # got calledThis is a Swift code

.swipeActions()
2024-05-08

.swipeActions()

Previously, we List rows were limited to only 1 swipe action - swipe to delete. Now, however, we can totally customize these rows and add a whole bunch of buttons to them. We will implement a few different variations of list row actions, each with

.badge
2024-05-08

.badge

@FocusState
2024-05-08

@FocusState

In practice, this will most often be associated with users clicking on TextFields. In this video, we will first learn what Focus State is and then review a few real-world implementations! As a bonus, we will also check out Apple's documentation on

TextSelection()
2024-05-07

TextSelection()

This is great for chat apps or any content-based app where users might want to share some text with a friend. Sharing is not only a great feature for your users, but will help drive organic growth as users share with others.

AsyncImage
2024-05-07

AsyncImage

Asynchronously download image from URLWhen the view appear, AsyncImage will read the data and put it inside the container. It will fetch the data every time we run the view.Image is bigger than the frame size, so other outside part will be cut off.No

System Material
2024-05-07

System Material

These System Materials are very commonly used as backgrounds for a subtle, yet professional look to your apps. As you'll see, the colors are not totally opaque and allow some natural color to bleed through.

.buttonStyle & .controlSize
2024-05-07

.buttonStyle & .controlSize

For the button Style, which one should I use?.buttonStyle(BorderlessButtonStyle())or.buttonStyle(.borderless)

@EnvironmentObject
2024-04-30

@EnvironmentObject

The @EnvironmentObject is a super-useful property wrapper that lets us put an observable object into the environment of our SwiftUI application. By doing this, all of these views in the view hierarchy will then have access to this object. This is

@AppStorage
2024-04-30

@AppStorage

We can save the small piece of data when the app is closed.Once we close the app on HomeView, we will never see the OnboardingView again.Important: @AppStorage writes your data to UserDefaults, which is not secure storage. As a result, you should

@StateObject & @ObservableObject
2024-04-29

@StateObject & @ObservableObject

Why is important?→ @StateObject → INIT→ @ObservedObejct → SubviewToday, I learned about ObservableObject and StateObject. These are property wrappers that observe other classes and update them in the view.Whenever the view is updated and reloaded,

Custom model
2024-03-18

Custom model

Custom data types are frequently needed in our applications. They allow us to incorporate multiple data points into a single model. For instance, a User's data may need to encompass more than just their name. By creating a custom data type, we can

Tap gesture
2024-03-15

Tap gesture

The .onTapGesture modifier functions much like a button and can even be customized to recognize multiple taps instead of just one (double-tap, triple-tap, etc.).count: number of taps to perform the actionjust like instagram.

onAppear & onDisappear
2024-03-12

onAppear & onDisappear

#modifierThe onAppear and onDisappear modifiers are extremely convenient methods that let us call functions when specific components appear or disappear from the screen. These are often used for managing animations and loading data in SwiftUI

SAFE CODING: if let & guard
2024-03-12

SAFE CODING: if let & guard

In Swift, variables can be declared as optional using the '?' symbol, indicating they may be nil. To safely check and unwrap these optional variables, 'if let' and 'guard' statements are recommended. These methods are safer than explicitly

toolbar
2024-03-11

toolbar

Adapting Dark Mode in visionOS??
2024-03-07

Adapting Dark Mode in visionOS??

VisionOS’s default colour scheme is “Default”We can change how it seems under preview by adding.preferredColorScheme(.light)or we can use the adaptive colour in assetsor we can create an enviroment variable to make it locally adaptive@Environment(\.c

add: Markups & Documentation
2024-03-07

add: Markups & Documentation

by writing // MARK: TITLE, it leaves a flag on minimap.and we can comment it like thisand we can fold it by pressing option+command+arrowwe can simplify the code by extracting subviews from the bodyWe can comment what this code is forUse

Slider
2024-02-28

Slider

Today, I explored Slider and TabView. While I had previously relied on NavigationStack for view composition, TabView simplifies navigation between different pages.Slider provides a user-friendly way to select from a range of values. It allows for

TabView()
2024-02-28

TabView()

Stepper
2024-02-01

Stepper

what is Strideable?We will create a rectangle that changes the size by clicking the stepperStepper enables users to increase or decrease a value by clicking the + and - signs.The view element can be edited or modified smoothly using withAnimation.I'm

DatePicker()
2024-01-18

DatePicker()

The DatePicker is a native SwiftUI component for selecting date and/or time.You can implement it using various initializers and customize it with different DatePickerStyles.Additionally, a DateFormatter can be used to effectively display dates in

ColorPicker()
2024-01-18

ColorPicker()

Picker()
2024-01-16

Picker()

toggle()
2024-01-15

toggle()

TextEditor()
2024-01-15

TextEditor()

TextField()
2024-01-11

TextField()

.contextMenu()
2024-01-11

.contextMenu()

#swiftui #visionos #applevisionpro #visionpro

function
2024-01-09

function

Let’s say we want to print this lines of string on the screen. It’s okay to use if this is on only one screen. But what if it’s on multiple pages?() are used with functions.() are known as the function’s call site: “a place where a function is

.actionSheet()
2024-01-08

.actionSheet()

.actionSheet() is not supported in VisionOS. Use .confirmationDialog() instead.In a popup screen, it's possible to list more than two buttons to modify the view.Vision Pro can be preordered starting from January 19 at 5AM PST.#visionOS

Alert
2024-01-06

Alert

Loop, While & Skip
2024-01-05

Loop, While & Skip

We can repeat and fix in array, dictionary, or setHeres an array of string, and print each string like following codeWe call the value of os from platforms.it will print 4 lines of textwe can loop over the fixed amount of number1...12 is "range"we

How to use List()
2024-01-04

How to use List()

#toolbarApple developer (List of Style)#visionOS #applevisionpro #swiftUI #appdevelopmentThis video provides the opportunity to experience a spatial video on my Quest 2. The immersion was remarkable, similar to viewing a 3D movie up close with 3D

NavigationStack & NavigationLink
2024-01-03

NavigationStack & NavigationLink

.sheet() vs .transition() vs .animation
2024-01-02

.sheet() vs .transition() vs .animation

Previous .transition() note, we only used a single button to toggle the screen.This time we will use @Binding and other button on the new screen to toggle.For your information, it appears really impressive.

.sheet() & .fullScreenCover()
2024-01-01

.sheet() & .fullScreenCover()

We didn’t assign anything on that “X” button, so we can’t go back to the screen.Someone told me, "you should learn AI instead of VisionOS."However, I'm interested in building experiences, which is why I'm focusing on MR.

Transition
2023-12-30

Transition

Use .transition to animate an object's entry and exit.❓When should we use .animation and .transition?💛 Playing with the .asymmetric transition effect can be fun.🫥 So, which one do we use the most?#visionOS #applevisionpro #swiftUI #appdevelopment

Adding Animation
2023-12-29

Adding Animation

2023-12-29 In SwiftUI, animations can be added using withAnimation(). A button and a rounded rectangle can be created, with a boolean variable isAnimated used to change the value of elements. The withAnimation() function provides animation features

Animation curves & timing
2023-12-29

Animation curves & timing

In most cases, we use Animation.default.However, it's enjoyable to experiment with different types of animations.👿 How can I animate all six squares using a single button?#visionOS #applevisionpro #swiftUI #studying

Subscribe to our newsletter

Get the latest news and updates from our team