How do I make a new view in Swift Playgrounds App Project in Xcode? Want I am wanting is to add a new screen to my app so when someone this a button on the home page, it will take them to another screen.
How do I make a new view in Swift Playgrounds App Project in Xcode?
Hi, Technically you could add a new subview to your playground like this:
class SecondView: UIView {
func loadView() {
let label = UILabel()
}
}
//and add this to your main views `loadView()`
let sView = SecondView()
sView.backgroundColor = .red
sView.frame = view.frame
sView.loadView()
But as soon as you want to use multiple views, windows or even navigate between them I highly recommend creating a sample project in Xcode using SwiftUI, or storyboard. It just is more convenient at this point.
Take care David