Posts covering APIs, tools and techniques for developing iOS apps
Use the new instance properties of the ShapeStyle in iOS 17 to access hierarchical system background styles, such as secondary and tertiary background.
This post will walk you through all the necessary setup so that you can enable remote push notification functionality in your iOS project.
Add icons to buttons in actionable push notifications using the UNNotificationActionIcon class to make notifications more intuitive and visually appealing.
Add custom foreground styles such as gradients to words inside Text view in SwiftUI in iOS 17.
Starting from iOS 17 and iPadOS 17 we can now use ControlGroup to display a horizontal collection of actions in a context menu.
Let's look into the new inspector() presentation API in iOS 17, iPadOS 17 and macOS 14 and see how to customise its width on iPad and Mac, and how to change the sheet style it defaults to on iPhone.
Ensure that complex SwiftUI buttons have the correct blending in pressed state by applying the compositingGroup() modifier.
Starting from Xcode 14, iOS simulator can generate a device token, allowing us to test remote push notifications coming from a server without a real device or a need to use .apns payload files and simctl push command.
Explore how to replace the position() modifier with a custom AnchoredPosition layout to improve flexibility in aligning views relative to an anchor point, and adjust the alignment dynamically based on available space.
Learn about different use cases for foregroundColor(), foregroundStyle() and tint() modifiers in SwiftUI to be able to choose the right API for the right purpose.
Adjust the the default appearance of the ShareLink button using SwiftUI view modifiers such as labelStyle(), imageScale() and symbolVariant().
Find out how text modifiers are different from view modifiers in SwiftUI and how we can use them in our code to style portions of text.
When we add an image name to a Localizable.strings file, SwiftUI automatically uses it for the image accessibility label.
Define custom sizing logic for UIViewRepresentable views in SwiftUI apps with the new iOS 16 sizeThatFits() API.
Create a chart with the Swift Charts framework to show UV index throughout the day inspired by the iOS Weather app that dims the area up to the current time.
Permanently position a view at the bottom of the screen in a SwiftUI app by placing it inside the safeAreaInset() modifier.
Use the accessibilityShowButtonShapes environment value to change the appearance of custom buttons and links embedded in Text views to make them more accessible.
Make sure that all of the necessary strings are localizable in a SwiftUI app by previewing your UI in the accented pseudolanguage.
Add a gradient to a bar chart that stretches from top to bottom of the plot area rather than filling each individual mark.
Generate xcloc files that can be sent to translators directly from SwiftUI code and import translations back to create Localizable.strings files.
Programmatically dismiss presentations and pop views from the navigation stack in both pure SwiftUI and hybrid UIKIt/SwiftUI apps with the help of the dismiss action.
Display a self-updating date and time inside a SwiftUI Text view and prevent the UI from moving as the digits in the date change.
Let users rename items from the navigation title in the toolbar using the new navigationTitle() modifier that takes a binding.
Make all parts of your app readable for users with low vision using the large content viewer APIs.
Set a custom background for TextEditor in SwiftUI by using a combination of scrollContentBackground() and background() view modifiers.
Build a bar chart using data with values of type Measurement<UnitDuration> that doesn't conform to Plottable by default.
Take advantage of the new URL APIs in iOS 16, which let us obtain paths to system directories more easily without the need to use FileManager methods.
Learn how to change the default position of y-axis in Swift Charts by using chartYAxis() modifier.
While reading the current color scheme is quite easy in SwiftUI, setting a color scheme requires us to carefully consider what effect we are trying to achieve.
Visualise data distributions by building a histogram and a 2D density plot with the new Swift Charts framework.
The default alignment of SwiftUI List row separators has changed in iOS 16. We also have some new APIs to customize separator insets.
Starting from iOS 16 and macOS 13 we have a SwiftUI API to request App Store reviews. We can read requestReview property from the environment and call it as a function at the appropriate time.
Tap gesture in SwiftUI now provides the tap location and we can request it in local or global coordinate space.
Starting from iOS 16 and macOS 13 SwiftUI List view can automatically generate move and delete operations without the need of onDelete() and onMove() closures.
With enhanced text modifiers in iOS 16 and macOS 13, it's easy to animate changes to text styles such as font size and weight.
Draw a custom SwiftUI view to replace the symbols in a scatter plot in Swift Charts.
Find and replace feature is automatically supported by SwiftUI TextEditor, but we also have some APIs to customize its behavior, such as disable replace or present the find UI programmatically.
New ViewThatFits API introduced at WWDC 2022 lets us create more flexible layouts in constrained space. It can even help us detect if text is truncated and adapt our views accordingly.
Build a custom ridge chart with the new Swift Charts framework to show the distribution of a numeric variable for several groups.
In this article we'll go over all the API additions in iOS 16 to present and customize resizable sheets in SwiftUI. We'll also look at API limitations comparing to UISheetPresentationController in UIKit.
Explore the capabilities of the new Swift Charts framework introduced at WWDC 2022 while making a stream graph with custom colour gradient and text labels.
Present a half-sheet in SwiftUI by specifying supported detents with the new presentationDetents() modifier in iOS 16.
Let's try out the new SwiftUI navigation APIs introduced in beta 1 for iOS 16 and macOS 13: NavigationStack, NavigationSplitView and ways to set up programmatic navigation.
Set custom background for a navigation bar in iOS 16 using new SwiftUI toolbarBackground() modifier.
Trigger actions with onChange() modifier in SwiftUI that depend on multiple properties changing by combining the logic in a computed property.
Find out about different ways we can provide feedback about new APIs to Apple engineers, ask questions during WWDC and get help from Apple experts and wider developer community.
Take a closer look at AttributedString type and different attribute scopes it can contain. Explore how Apple system frameworks interpret available attributes and how to create your own.
Learn how to size and scale symbol images in SwiftUI and why we shouldn't use resizable() modifier with SF Symbols.
Add custom encoding and decoding logic for SwiftUI Color that is not Codable by default to be able to save it to disk or remote database.
Hide and show a view based on a setting or state without shifting the layout by using opacity() modifier in SwiftUI.
Look into how to insert images, formatted data, attributed strings etc. inside SwiftUI Text views by leveraging the power of string interpolation in LocalizedStringKey.
Present multiple sheets at the same time one on top of the other like, for example, in Apple Calendar app when adding a new calendar.
We have several ways to customize the visual style of links placed inside Text views in SwiftUI: tint() modifier, different Text modifiers and attributes in AttributedString.
SwiftUI Text views can automatically parse Markdown strings when created with LocalizedStringKey. Markdown isn't parsed when created with a String variable or with verbatim initializer.
Customize actions for links inside Text views in SwiftUI by using openURL environment value.
Set underline and strikethrough styles in AttributedString and display it with SwiftUI Text view.
Set a keypath to your model properties as FocusState value to avoid declaring custom enums to programmatically set focus and respond to focus changes.
Allow users to select the contents of SwiftUI Text view, to be able to copy or share it, by applying textSelection() modifier.
Learn how to rapidly evaluate a polynomial function of variable size on the GPU without needing to write C++ Metal shaders.
Make use of the focused scene value API to pass data from the focused scene to the commands section of the app.
Make an editable list of items in SwiftUI that automatically adds an empty text field for users to easily add new entries.
Integrate with UndoManager in SwiftUI by building a reusable UndoProvider view that can be used with any binding.
Add RawRepresentable conformance to a custom type that represents a setting or a view state in SwiftUI to be able to save it in AppStorage or SceneStorage.
Remove the default TextEditor background on iOS and add a placeholder that is not currently supported in TextEditor out of the box.
Let users preview various file formats such as Images, Live Photos, PDFs etc. in your SwiftUI app using QuickLook framework.
Provide state restoration for expanded rows in a SwiftUI List view with SceneStorage property wrapper.
Explore how to add support for local network privacy if, for example, your app uses URLSession to access local servers.
Programmatically scroll SwiftUI ScrollView to a newly added item by combining ScrollViewReader and onChange() view modifier.
Implement state restoration in an example tab-based app that stores records of different types of trips.
View and manage files created by your app on the simulator, browse the Documents folder or Core Data SQLite Database.
Programmatically scroll SwiftUI List to a particular item, using the fact that its internal implementation is based on UITableView.
Add keyboard shortcuts to a SwiftUI iOS/iPadOS app to improve user experience when using your app with an attached hardware keyboard.
If you need to release an app built with an older version of Xcode, but want to test the app on the beta iOS simulators, you can follow the steps described in this article to transfer your build to the beta simulator.
Define and use custom environment key-value pairs in SwiftUI to pass values to the hierarchy of child views.
Make a scrollable view in SwiftUI scroll the active text field into visible range when the keyboard appears on screen in iOS 13.
In this article we would like to share what we learned about buttons in SwiftUI List rows when developing our apps.