Skip to main content
Apple Sample Code
Contents
authenticationservices (4)
automaticassessmentconfiguration (1)
devicediscoveryextension (1)
imageio (1)
- Writing spatial photosSample Code— Create spatial photos for visionOS by packaging a pair of left- and right-eye im...
pdfkit (2)
- Custom GraphicsSample Code— Demonstrates adding a watermark to a PDF page.
- PDF WidgetsSample Code— Demonstrates adding widgets—interactive form elements—to a PDF document.
swiftui (34)
- Add rich graphics to your SwiftUI appSample Code— Make your apps stand out by adding background materials, vibrancy, custom graphi...
- Adopting drag and drop using SwiftUISample Code— Enable drag-and-drop interactions in lists, tables and custom views.
- Backyard Birds: Building an app with SwiftData and widgetsSample Code— Create an app with persistent data, interactive widgets, and an all new in-app p...
- Bringing multiple windows to your SwiftUI appSample Code— Compose rich views by reacting to state changes and customize your app’s scene p...
- Bringing robust navigation structure to your SwiftUI appSample Code— Use navigation links, stacks, destinations, and paths to provide a streamlined e...
- Building a document-based app using SwiftDataSample Code— Code along with the WWDC presenter to transform an app with SwiftData.
- Building a document-based app with SwiftUISample Code— Create, save, and open documents in a multiplatform app.
- Building a great Mac app with SwiftUISample Code— Create engaging SwiftUI Mac apps by incorporating side bars, tables, toolbars, a...
- Building rich SwiftUI text experiencesSample Code— Build an editor for formatted text using SwiftUI text editor views and attribute...
- Composing advanced graphics effects with SwiftUISample Code— Create compelling visuals in your app by combining graphical effects.
- Composing custom layouts with SwiftUISample Code— Arrange views in your app’s interface using layout tools that SwiftUI provides.
- Controlling the timing and movements of your animationsSample Code— Build sophisticated animations that you control using phase and keyframe animato...
- Creating a tvOS media catalog app in SwiftUISample Code— Build standard content lockups and rows of content shelves for your tvOS app.
- Creating accessible viewsSample Code— Make your app accessible to everyone by applying accessibility modifiers to your...
- Creating accessible viewsSample Code— Make your app accessible to everyone by applying accessibility modifiers to your...
- Creating custom container viewsSample Code— Access individual subviews to compose flexible container views.
- Creating visual effects with SwiftUISample Code— Add scroll effects, rich color treatments, custom transitions, and advanced effe...
- Customizing window styles and state-restoration behavior in macOSSample Code— Configure how your app’s windows look and function in macOS to provide an engagi...
- Enhancing your app’s content with tab navigationSample Code— Keep your app content front and center while providing quick access to navigatio...
- Focus Cookbook: Supporting and enhancing focus-driven interactions in your SwiftUI appSample Code— Create custom focusable views with key-press handlers that accelerate keyboard i...
- Food Truck: Building a SwiftUI multiplatform appSample Code— Create a single codebase and app target for Mac, iPad, and iPhone.
- Landmarks: Applying a background extension effectSample Code— Configure an image to blur and extend under a sidebar or inspector panel.
- Landmarks: Building an app with Liquid GlassSample Code— Enhance your app experience with system-provided and custom Liquid Glass.
- Landmarks: Displaying custom activity badgesSample Code— Provide people with a way to mark their adventures by displaying animated custom...
- Landmarks: Extending horizontal scrolling under a sidebar or inspectorSample Code— Improve your horizontal scrollbar’s appearance by extending it under a sidebar o...
- Landmarks: Refining the system provided Liquid Glass effect in toolbarsSample Code— Organize toolbars into related groupings to improve their appearance and utility...
- Loading and displaying a large data feedSample Code— Consume data in the background, and lower memory use by batching imports and pre...
- Loading and displaying a large data feedSample Code— Consume data in the background, and lower memory use by batching imports and pre...
- Making a card game with drag, drop, and reordering in SwiftUISample Code— Move cards between positions in a card game using drag, drop, and reordering mod...
- Managing model data in your appSample Code— Create connections between your app’s data model and views.
- Migrating from the Observable Object protocol to the Observable macroSample Code— Update your existing app to leverage the benefits of Observation in Swift.
- Monitoring data changes in your appSample Code— Show changes to data in your app’s user interface by using observable objects.
- Restoring your app’s state with SwiftUISample Code— Provide app continuity for users by preserving their current activities.
- Wishlist: Planning travel in a SwiftUI appSample Code— Build a travel planning app that organizes trips into collections and tracks act...
uikit (48)
- Add Home Screen quick actionsSample Code— Expose commonly used functionality with static or dynamic 3D Touch Home Screen q...
- Adding context menus in your appSample Code— Provide quick access to useful actions by adding context menus to your iOS app.
- Adding hardware keyboard support to your appSample Code— Enhance interactions with your app by handling raw keyboard events, writing cust...
- Adding menus and shortcuts to the menu bar and user interfaceSample Code— Provide quick access to useful actions by adding menus and keyboard shortcuts to...
- Adjusting your layout with keyboard layout guideSample Code— Respond dynamically to keyboard movement by using the tracking features of the k...
- Adopting drag and drop in a custom viewSample Code— Demonstrates how to enable drag and drop for a UIImageView instance.
- Adopting drag and drop in a table viewSample Code— Demonstrates how to enable and implement drag and drop for a table view.
- Adopting hover support for Apple PencilSample Code— Enhance user feedback for your iPadOS app with a hover preview for Apple Pencil ...
- Adopting iOS Dark ModeSample Code— Adopt Dark Mode in your iOS app by using dynamic colors and visual effects.
- Adopting menus and UIActions in your user interfaceSample Code— Add menus to your user interface, with built-in button support and bar-button it...
- Asynchronously loading images into table and collection viewsSample Code— Store and fetch images asynchronously to make your app more responsive.
- Building a document browser app for custom file formatsSample Code— Implement a custom document file format to manage user interactions with files o...
- Building an app with a document browserSample Code— Provide access to on-device and cloud files by adding a document browser to your...
- Building and improving your app with Mac CatalystSample Code— Improve your iPadOS app with Mac Catalyst by supporting native controls, multipl...
- Building high-performance lists and collection viewsSample Code— Improve the performance of lists and collections in your app with prefetching an...
- Changing the appearance of selected and highlighted cellsSample Code— Provide visual feedback to the user about the state of a cell and the transition...
- Creating self-sizing table view cellsSample Code— Create table view cells that support Dynamic Type and use system spacing constra...
- Customizing an image picker controllerSample Code— Manage user interactions and present custom information when taking pictures by ...
- Customizing and resizing sheets in UIKitSample Code— Discover how to create a layered and customized sheet experience in UIKit.
- Customizing collection view layoutsSample Code— Customize a view layout by changing the size of cells in the flow or implementin...
- Customizing your app’s navigation barSample Code— Create custom titles, prompts, and buttons in your app’s navigation bar.
- Data delivery with drag and dropSample Code— Share data between iPad apps during a drag and drop operation using an item prov...
- Detecting changes in the preferences windowSample Code— Listen for and respond to a user’s preference changes in your Mac app built with...
- Disabling the pull-down gesture for a sheetSample Code— Ensure a positive user experience when presenting a view controller as a sheet.
- Display text with a custom layoutSample Code— Lay out text in a custom-shaped container and apply glyph substitutions.
- Displaying searchable content by using a search controllerSample Code— Create a user interface with searchable content in a table view.
- Enhancing your iPad app with pointer interactionsSample Code— Provide a great user experience with pointing devices, by incorporating pointer ...
- Enriching your text in text viewsSample Code— Support line numbering, section collapsing, inline attachment caching, exclusion...
- Illustrating the force, altitude, and azimuth properties of touch inputSample Code— Capture Apple Pencil and touch input in views.
- Implementing modern collection viewsSample Code— Bring compositional layouts to your app and simplify updating your user interfac...
- Implementing Peek and PopSample Code— Accelerate actions in your app by providing shortcuts to preview content in deta...
- Integrating pointer interactions into your iPad appSample Code— Support touch interactions in your iPad app by adding pointer interactions to yo...
- Leveraging touch input for drawing appsSample Code— Capture touches as a series of strokes and render them efficiently on a drawing ...
- Navigating an app’s user interface using a keyboardSample Code— Navigate between user interface elements using a keyboard and focusable UI eleme...
- Prefetching collection view dataSample Code— Load data for collection view cells before they display.
- Restoring your app’s stateSample Code— Provide continuity for the user by preserving current activities.
- Selecting multiple items with a two-finger pan gestureSample Code— Accelerate user selection of multiple items using the multiselect gesture on tab...
- Showing help tags for views and controls using tooltip interactionsSample Code— Explain the purpose of interface elements by showing a tooltip when a person pos...
- Supporting desktop-class features in your iPad appSample Code— Enhance your iPad app by adding desktop-class features and document support.
- Supporting gesture interaction in your appsSample Code— Enrich your app’s user experience by supporting standard and custom gesture inte...
- Supporting HDR images in your appSample Code— Load, display, edit, and save HDR images using SwiftUI and Core Image.
- Supporting multiple windows on iPadSample Code— Support side-by-side instances of your app’s interface and create new windows.
- Synchronizing documents in the iCloud environmentSample Code— Manage documents across multiple devices to create a seamless editing and collab...
- UIKit Catalog: Creating and customizing views and controlsSample Code— Customize your app’s user interface with views and controls.
- Updating collection views using diffable data sourcesSample Code— Streamline the display and update of data in a collection view using a diffable ...
- Using suggested searches with a search controllerSample Code— Create a search interface with a table view of suggested searches.
- Using SwiftUI with UIKitSample Code— Learn how to incorporate SwiftUI views into a UIKit app.
- Using TextKit 2 to interact with textSample Code— Interact with text by managing text selection and inserting custom text elements...
visionos (48)
- Accessing the main cameraSample Code— Add camera-based features to enterprise apps.
- Adding a depth effect to text in visionOSSample Code— Create text that expands out of a window using stacked SwiftUI text views.
- Animating hand models in visionOSSample Code— Substitute a person’s hands with custom models in a fully immersive space.
- Applying mesh to real-world surroundingsSample Code— Add a layer of mesh to objects in the real world, using scene reconstruction in ...
- Associating a window with an immersive spaceSample Code— Tightly couple a window with an immersive space for persistent controls.
- BOT-anistSample Code— Build a multiplatform app that uses windows, volumes, and animations to create a...
- Building an immersive media viewing experienceSample Code— Add a deeper level of immersion to media playback in your app with RealityKit an...
- Building local experiences with room trackingSample Code— Use room tracking in visionOS to provide custom interactions with physical space...
- Canyon Crosser: Building a volumetric hike-planning appSample Code— Create a hike planning app using SwiftUI and RealityKit.
- Connecting iPadOS and visionOS apps over the local networkSample Code— Build an iPadOS companion app to control your visionOS app.
- Creating 2D shapes with SwiftUISample Code— Draw two-dimensional shapes in your visionOS app with SwiftUI shapes or with you...
- Creating 3D entities with RealityKitSample Code— Display a horizontal row of three-dimensional shapes in your visionOS app, using...
- Creating 3D models as movable windowsSample Code— Display 3D content with a volumetric window that people can move.
- Creating a 3D painting spaceSample Code— Implement a painting canvas entity, and update its mesh to represent a stroke.
- Creating an immersive space in visionOSSample Code— Enhance your visionOS app by adding an immersive space using RealityKit.
- Creating an interactive 3D model in visionOSSample Code— Display an interactive car model using gestures in a reality view.
- Creating SwiftUI windows in visionOSSample Code— Display and manage multiple SwiftUI windows in your visionOS app.
- Destination VideoSample Code— Leverage SwiftUI to build an immersive media experience in a multiplatform app.
- DioramaSample Code— Design scenes for your visionOS app using Reality Composer Pro.
- Displaying a 3D environment through a portalSample Code— Implement a portal window that displays a 3D environment and simulates entering ...
- Displaying a stereoscopic imageSample Code— Build a stereoscopic image by applying textures to the left and right eye in a s...
- Displaying an entity that follows a person’s viewSample Code— Create an entity that tracks and follows head movement in an immersive scene.
- Displaying text in visionOSSample Code— Create styled text in a window using SwiftUI.
- Displaying video from connected devicesSample Code— Show video from devices connected with the Developer Strap in your visionOS app.
- Drawing in the air and on surfaces with a spatial stylusSample Code— Create a spatial stylus drawing experience that balances latency and accuracy fo...
- Embedding controls in an immersive spaceSample Code— Keep controls visible throughout an immersive experience by displaying them in a...
- Enabling video reflections in an immersive environmentSample Code— Create a more immersive experience by adding video reflections in a custom envir...
- Exploring object tracking with ARKitSample Code— Find and track real-world objects in visionOS using reference objects you train ...
- Gaussian splats on visionOSSample Code— Use the new Gaussian splat APIs available in RealityKit in visionOS 27.
- Generating procedural texturesSample Code— Display a 3D model that generates procedural textures in a reality view.
- Handling the window life cycle with multiple scenesSample Code— Track scene state across different window types.
- Happy BeamSample Code— Leverage a Full Space to create a fun game using ARKit.
- Hello WorldSample Code— Use windows, volumes, and immersive spaces to teach people about the Earth.
- Implementing adjustable materialSample Code— Update the adjustable parameters of a 3D model in visionOS.
- Implementing SharePlay for immersive spaces in visionOSSample Code— Enable collaborative spatial experiences by using SharePlay to synchronize 3D co...
- Incorporating real-world surroundings in an immersive experienceSample Code— Create an immersive experience by making your app’s content respond to the local...
- Locating and decoding barcodes in 3D spaceSample Code— Create engaging, hands-free experiences based on barcodes in a person’s surround...
- Manipulating entities with solid collisionsSample Code— Extend the capabilities of your app by using entities, components, and systems t...
- Object tracking with Reality Composer Pro experiencesSample Code— Use object tracking in visionOS to attach digital content to real objects to cre...
- Obscuring virtual items in a scene behind real-world itemsSample Code— Increase the realism of an immersive experience by adding entities with invisibl...
- Petite Asteroids: Building a volumetric visionOS gameSample Code— Use the latest RealityKit APIs to create a beautiful video game for visionOS.
- Placing content on detected planesSample Code— Detect horizontal surfaces like tables and floors, as well as vertical planes li...
- Placing entities using head and device transformSample Code— Query and react to changes in the position and rotation of Apple Vision Pro.
- Playing immersive media with RealityKitSample Code— Create an immersive video playback experience with RealityKit.
- Playing spatial audioSample Code— Create and adjust spatial audio in visionOS with RealityKit.
- Swift SplashSample Code— Use RealityKit to create an interactive ride in visionOS.
- Tracking and visualizing hand movementSample Code— Use hand-tracking anchors to display a visual representation of hand transforms ...
- Tracking specific points in world spaceSample Code— Retrieve the position and orientation of anchors your app stores in ARKit.