Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the size of the Xcode Playground Simulator when using live view?

I created a Swift Playground on my iPad and did all of my graphics positioning on the iPad simulator. Does anyone know how to edit the size of the Xcode playground simulator? Thanks in advance.

like image 676
Johnd Avatar asked Apr 02 '17 00:04

Johnd


People also ask

What is the difference between playground and Xcode?

An Xcode project allows you to create real apps that you could eventually upload to the App Store (providing you became an Apple Developer). An Xcode Playground allows you to play with code and test it out.

Can you use SwiftUI in playgrounds?

Overview. In Swift Playgrounds, you can see live Previews of your SwiftUI views just like Previews in Xcode. In a . swiftpm project, you have a default App Preview that generates from the structure that conforms to the App protocol.

How do I use a playground in Xcode 12?

To use this new feature, start by opening up the Xcode 12 beta and create a new playground using the File > New > Playground command. Then, once you've picked your platform of choice and your playground has been created, convert it into an Xcode workspace by selecting File > Save As Workspace .

How do I use Xcode playground?

To open Playground on Xcode, navigate to File in the menu and click on New > Playground... To test our square function, we will choose the Blank template. Name your Playground file, then click on Create.


1 Answers

import PlaygroundSupport
import UIKit

let viewController = UIViewController()
viewController.view.frame = CGRect(x: 0, y: 0, width: 320, height: 568)
PlaygroundPage.current.liveView = viewController

Seems to me this is the only working example at the moment (Xcode 12.5). Setting the view.frame is the key here.

like image 148
Roman Aliyev Avatar answered Nov 15 '22 20:11

Roman Aliyev