1. Working with SwiftUI in Xcode
2. Primitive Layout Components
3. Layering Views
4. Positioning Views
5. Sizing Views
6. Reusable Layout Components
7. Custom Layout
8. Dynamic Data
9. ScrollView
10. Adaptive Layout
11. System Containers: List, Form and Table

1.2 Working with the Canvas in Xcode

Please login for access. Login

In this section, we will explore the various features and options available in the Canvas in Xcode. The Canvas provides a real-time preview of your SwiftUI layout, allowing you to quickly iterate and test your designs.

At the bottom of the Canvas, you will find a range of options to enhance your previewing experience. Let’s take a closer look at each of these features:

Zooming and Fit on Screen

On the right side of the Canvas, you can find options to zoom in or fit the layout on the screen. These options help you view your design more closely or fit it to the available space.

Device Preview

The toggle next to the zoom options allows you to select the device for the preview. By default, the preview matches the device selected for your run target.


To make testing and debugging more efficient, Xcode offers variants for color schemes, orientations, and dynamic type sizes. By enabling variants, you can compare different options side by side and quickly identify any issues or inconsistencies in your layout.

 Selectable Preview

In the canvas area choose the second button in the bottom left corner to use the selectable preview feature. You can double-click on a specific view to highlight the corresponding code in the editor. This feature is particularly useful when working with complex views or collections, as it helps you identify which code snippets correspond to which views.

Live Preview

The live preview feature is handy for testing animations and interactions in real time. It allows you to see how your views respond to user interactions, such as tapping a button or scrolling a scroll view.

Device Settings

The “Device Settings” option allows you to customize the preview environment further. You can set specific color schemes, test landscape or portrait orientations, and even experiment with dynamic type sizes. These settings help you ensure your layout adapts well to different scenarios.

Post a comment

Leave a Comment