SwiftUI_visionOS_Note

SwiftUI_visionOS_Note

Anything I learnt today about building visionOS app

All

N - Voice Record

N - Voice Record

.onLongPressGesture
2024-05-27

.onLongPressGesture

MagnificationGesture
2024-05-27

MagnificationGesture

Map
2024-05-21

Map

While most iOS tutorials are engaging, they often don't function well on visionOS. I spend the most of time modifying them to work, either intentionally or unintentionally.
ToDo List
2024-05-15

ToDo List

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
.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
@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
.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

.buttonStyle & .controlSize
2024-05-07

.buttonStyle & .controlSize

For the button Style, which one should I use?.buttonStyle(BorderlessButtonStyle())or.buttonStyle(.borderless)
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.
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
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.
@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
@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
@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

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
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
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()