Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import SwiftUI
struct GameDetail: View {
@State var nowDate = Date()
private var refDate: Date {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-MM-dd HH:mm:ss"
let rDate = formatter.date(from: "20019-10-11 12:12:12")
return rDate!
}
private var timer: Timer {
return Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
self.nowDate = Date()
}
}
var body: some View {
VStack {
Image(uiImage: UIImage(named: "gameImage")!)
.resizable()
.aspectRatio(contentMode: .fit)
.cornerRadius(10.0)
Text("\(nowDate.distance(to: refDate).description) Until game release")
}
.onAppear {
_ = self.timer
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
GameDetail()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment