Movatterモバイル変換


[0]ホーム

URL:


Khoa Pham
Khoa Pham

Ohayo

Swift Discovery

Discover all the tech

Search for the blog

Featured

My year in review 2020

Issue#715

I remember this time last year in December 2019, I spent almost every single bit of my free time onPuma because I want a Swift friendly version of fastlane that suits my need and leverages Swift 5 features.

Here’s my review of my …

Khoa Pham
Written by

How to use playground in Swift file

Issue#998

Traditionally, if we wanted to quickly test a function or a piece of logic, we would open a separate Playground file (.playground).

From Xcode 26 we can have access to the new#Playground macro in Swift 6.2. This allows us to declare a …

Khoa Pham
Written by

How to morph liquid glass view transition

Issue#997

An interesting feature in iOS 26 is the ability to create morph “Liquid Glass” effects, where views with the.glassEffect() modifier can fluidly morph into one another. This is achieved usingGlassEffectContainer and the …

Khoa Pham
Written by

How to prompt users to configure widgets in iOS 18

Issue#996

When creating widgets for iOS, especially those that need user input to be useful, one common challenge is guiding the user to configure them. Before iOS 18, a user would add a widget, but then would have to know to long-press it and …

Khoa Pham
Written by

How to make zoom transition animation in iOS 18

Issue#995

With iOS 18, SwiftUI introducesmatchedTransitionSource andnavigationtransition as a powerful new way to create zoom animations between views. This allows you to smoothly transition from a small view to a larger, more detailed view, …

Khoa Pham
Written by

How to create mesh gradient in iOS 18

Issue#994

With iOS 18, Apple introduced a powerful new tool for creating beautiful, dynamic backgrounds:MeshGradient. Forget simple two-color gradients; mesh gradients let you blend a whole grid of colors together smoothly, creating stunning, …

Khoa Pham
Written by

How to animate number change from iOS 17

Issue#993

Before iOS 17, if you wanted to animate a number changing, SwiftUI would just fade the old number out and fade the new one in. It worked, but it wasn’t very exciting.

Here’s how that looked:

structOldCounterView:View{@ …

Khoa Pham
Written by

How to observe model changes in iOS 26

Issue#992

In the past, making your screen update when data changed in UIKit meant writing extra code, either with didSet, Combine or some other callbacks. Now, it’s automatic.

With the latest iOS 26 updates, UIKit can automatically watch your …

Khoa Pham
Written by

How SwiftUI StateObject and React useState defer initial value evaluation

Issue#991

When building apps inSwiftUI orReact, we often need to store values that change — like a counter, user input, or a list of items.

To do this:

  • React gives ususeState.
  • SwiftUI gives us@State and@StateObject.

But here’s something cool: …

Khoa Pham
Written by

How to tap again on tab bar item to scroll top in iOS

Issue#990

In many popular apps like LinkedIn, Reddit, we can tap again on a bar bar item to scroll to top. Although this behavior is not built in by iOS, we can implement that very easily.

The idea is to keep track ofprevious selection so we can …

Khoa Pham
Written by

How to make NSImage Sendable in Swift

Issue#989

In Swift 6, Apple introduced stricter rules to help make your code safer when using concurrency (like async, await, Task, and actor). These rules check that types used in concurrent code are safe to share across threads.

Types that are …

Khoa Pham
Written by

How to observe optional ObservableObject in SwiftUI

Issue#988

When working with Core Data, there are times we have optionalNSManagedObject to pass around. These objects conform toObservableObject, and in SwiftUI we can’t@ObservedObject on optionalObservableObject

One way we can workaround …

Khoa Pham
Written by

How to clear background for TextField inside list in macOS

Issue#986

When using TextField in SwiftUI List on Mac, it has unwanted background color when focused. We can turn it off using introspection or a custom TextField wrapper

TextField("Search",text:$searchText).introspect(.textField,on: …

Khoa Pham
Written by

How to use GitHub Copilot for Xcode

Issue#985

DuringGitHub Universe 2024, GitHub announced thatGitHub Copilot code completion in Xcode is available in public preview. The project is open source atCopilotForXcode

image

GitHub Copilot has been available asVS Code extension for a while, …

Khoa Pham
Written by

How to conditionally render widgets in iOS

Issue#984

TheWidgetBundle lets us expose multiple widgets from a single widget extension

It usesWidgetBundleBuilder to constructs a widget bundle’s body.

In iOS 18, if we includeControlWidget then we need to checkiOSApplicationExtension iOS 18. …

Khoa Pham
Written by

How to open app with Control Widget on iOS 18

Issue#983

In iOS 18, we can make Control Widget in Widget extension

importWidgetKitimportSwiftUI@available(iOS18.0,*)structBookControlWidget:ControlWidget{varbody:someControlWidgetConfiguration{StaticControlConfiguration …

Khoa Pham
Written by

How to use NSFetchedResultsController memory wise in Core Data

Issue#982

If you’re usingNSFetchedResultsController in Core Data, it might take up a lot of memory, especially when working with large datasets. To keep your app running smoothly, it’s important to manage memory efficiently

Use Fetch Limits and …

Khoa Pham
Written by

How to use NSDragOperation

Issue#981

NSDragOperation represent which operations the dragging source can perform on dragging items.

There are several types of drag operations, and each one has a different purpose and visual cue.

Copy Operation.copy

  • What It Does: The item …

Khoa Pham
Written by

How to make NSCollectionView with diffable data source and SwiftUI

Issue#980

NSCollectionView, available since macOS 10.5+, is a good choice to present a list of content. Let’s make a SwiftUI wrapper forNSCollectionView with diffable data source and compositional layout

Use NSViewControllerRepresentable …

Khoa Pham
Written by

How to use React Query useQuery with debounce

Issue#979

When dealing with user input, such as in an autocomplete component, it’s common to implement debouncing to reduce the number of API calls and improve the user experience.

React Query’suseQuery hook makes it easy to manage the …

Khoa Pham
Written by

How to handle tap gesture in SwiftUI Charts

Issue#978

From iOS 17, SwiftUI Charts haschartGesture, together withSpatialTapGesture we can check tap location and convert that to Charts value

Chart{}.chartGesture{chartinSpatialTapGesture().onEnded{valuein …

Khoa Pham
Written by
Khoa Pham

Hello, I’m Khoa

I’m a thinker and storyteller with a passion for exploring the intersection of creativity and technology

🧑‍💻 I love crafting high quality and useful apps🔥 I love open source. My GitHub open source has 2.3k followers with packages that are integrated by 45k+ apps and over 3.4m+ downloads on CocoaPods.✍️ I write here on my blog and on Medium, which has over 2.7k+ followers with tons of articles and 90k+ monthly views.🖥 Follow me for sharings about Swift, SwiftUI, iOS and macOS development.
Hei

[8]ページ先頭

©2009-2025 Movatter.jp