欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

016_swiftui_日期的使用

程序员文章站 2022-05-30 13:48:50
...
//
//  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()
    }
}

效果

016_swiftui_日期的使用

相关标签: # swiftUI