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

走远了吗. 提交于 2019-12-08 16:47:27

问题


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.


回答1:


To change the size of a playground's liveView, set the preferredContentSize of the viewController.

import PlaygroundSupport
import UIKit

let viewController = UIViewController()
viewController.preferredContentSize = CGSize(width: 600, height: 600)
PlaygroundPage.current.liveView = viewController



回答2:


let vc = ViewController()
vc.view.frame.size = CGSize(width: 375, height: 667)
PlaygroundPage.current.liveView = vc.view


来源:https://stackoverflow.com/questions/43163383/how-to-change-the-size-of-the-xcode-playground-simulator-when-using-live-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!