How can I read an asset from an asset catalog?
Asked on 07/31/2024
1 search
To read an asset from an asset catalog, you can reference the asset in your code. Here are some relevant details from the WWDC sessions:
-
Using Swiftassist to Reference Assets:
- In the Platforms State of the Union session, it was demonstrated how Swiftassist can help reference images from an asset catalog. Swiftassist can create a struct that includes an image name property, and then update sample data with image names from the asset catalog.
-
Dynamic Type and Asset Catalogs:
- In the Get started with Dynamic Type session, it was shown how to use the scaled metric API to let images resize based on the selected text size. This involves adding scaled metric and specifying the width or height of the image, which will be automatically scaled at runtime.
-
Fetching Assets Programmatically:
- In the Build compelling spatial photo and video experiences session, it was explained how to use Photokit to programmatically fetch assets from the user's photo library. You can set specific media subtypes when constructing your fetch predicate to filter the assets.
These sessions provide a comprehensive overview of how to work with assets in your app, from referencing them in your code to dynamically adjusting their size and fetching them programmatically.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Build compelling spatial photo and video experiences
Learn how to adopt spatial photos and videos in your apps. Explore the different types of stereoscopic media and find out how to capture spatial videos in your iOS app on iPhone 15 Pro. Discover the various ways to detect and present spatial media, including the new QuickLook Preview Application API in visionOS. And take a deep dive into the metadata and stereo concepts that make a photo or video spatial.

Get started with Dynamic Type
Dynamic Type lets people choose their preferred text size across the system and all of their apps. To help you get started supporting Dynamic Type, we’ll cover the fundamentals: How it works, how to find issues with scaling text in your app, and how to take practical steps using SwiftUI and UIKit to create a great Dynamic Type experience. We’ll also show how you can best use the Large Content Viewer to make navigation controls accessible to everyone.