https://github.com/wk1/xcode-playground-canvas
A SwiftUI wrapper that provides a framed Live View for Xcode Playgrounds, simulating a more structured UI environment.
https://github.com/wk1/xcode-playground-canvas
candy snippet swift ui
Last synced: 2 months ago
JSON representation
A SwiftUI wrapper that provides a framed Live View for Xcode Playgrounds, simulating a more structured UI environment.
- Host: GitHub
- URL: https://github.com/wk1/xcode-playground-canvas
- Owner: wk1
- Created: 2025-02-17T13:15:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-17T13:17:07.000Z (over 1 year ago)
- Last Synced: 2025-07-07T07:48:32.058Z (about 1 year ago)
- Topics: candy, snippet, swift, ui
- Language: Swift
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PlaygroundCanvas 🖥️🎨 – A Framed Live View for Swift Playgrounds
**PlaygroundCanvas** is a lightweight SwiftUI wrapper designed to enhance the experience of using SwiftUI in Xcode Playgrounds. It provides a **fixed outer frame** for the Live View, ensuring that SwiftUI behaves more consistently with how it would in a real Swift Playgrounds environment.
## ✨ Features
- 📏 **Fixed Frame** (480x720) to simulate a real device or structured layout
- 🎨 **Subtle Styling** with gradients, rounded corners, and a soft border for a polished look
- 🎭 **Encapsulation** to make the Live View experience more predictable and visually appealing
- 🛠️ **Easy Integration** – Simply wrap your SwiftUI view inside `PlaygroundCanvas`
## 🏗️ Usage
```swift
import SwiftUI
import PlaygroundSupport
PlaygroundPage.current.setLiveView(
PlaygroundCanvas {
ContentView() // Replace with your own view
}
)
```
## 🎯 Why Use This?
When working with **SwiftUI in Xcode Playgrounds**, the default Live View can feel inconsistent, especially compared to Swift Playgrounds on iPad. `PlaygroundCanvas` provides a **structured environment**, making it easier to design, test, and prototype UI components with a more **device-like experience**.