SwiftUI in Playgrounds - show関数

2019年11月6日水曜日

Swift Playgrounds SwiftUI

t f B! P L


LiveViewをセットするシュガーシンタックス。



// Code inside modules can be shared between pages and other source files.

import SwiftUI
import PlaygroundSupport

public func show<incomingview>(_ newLiveView: IncomingView, wantsFullScreen: Bool=true) where IncomingView : View {
    #if os(iOS)
    PlaygroundPage.current.wantsFullScreenLiveView = wantsFullScreen
    #endif
    PlaygroundPage.current.setLiveView(newLiveView)
}

使い方

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("SwiftUI")
    }
}

show(ContentView(), wantsFullScreen:false)

このブログを検索

人気の投稿

ラベル

QooQ