//
// ContentView.swift
// learn_swiftUi
//
// Created by liuan on 2020/5/14.
// Copyright © 2020 liuan. All rights reserved.
//
import SwiftUI
struct ContentView: View {
var now=Date()
static let dateFormatter:DateFormatter = {
let formatter=DateFormatter()
formatter.dateStyle = .long
formatter.dateStyle = .full
return formatter
}()
var body: some View {
Text("当前日期\(now,formatter: Self.dateFormatter)")
.frame(minWidth: 0, maxWidth: .infinity,minHeight: 0,maxHeight: .infinity)
.background(Color.orange)
.font(.largeTitle)
.edgesIgnoringSafeArea(.all)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
效果