swiftxcode11ios14wwdcplaygrounds

how to resize a view in live playgrounds ?? Xcode


I am planning to create a live playground for coming wwdc scholarships but I have no experience in creating live playgrounds because I have worked with single view apps so far

I actually don't know what size should be the view in my playground and I am not able to resize it can any one tell me how to do that , I have tried the below code but it gives me error and doesn't work please help me and any advice related to wwdc project is appreciated thank you

 let main = viewController()
main.view.frame.size = CGSize(width: 300, height: 600)

this code gives error:= expression failed to parse, unknown error

Please tell me how to resize the view and also how should I do it ??


Solution

  • You should change entire frame or bounds properties to resize the view:

    import UIKit
    import PlaygroundSupport
    
    class ViewController : UIViewController {
        ...
    }
    
    let viewController = ViewController()
    viewController.view.frame = CGRect(x: 0, y: 0, width: 300, height: 600)
    PlaygroundPage.current.liveView = viewController
    PlaygroundPage.current.needsIndefiniteExecution = true