Hi. I need to see one preview at specific date. How i can run preview at that date?
How to define a system date for SwiftUI Preview?
You can also change the time in your code.
You change your specific date to your current date.
Thank for the answer, but, how i can pass my current date (generated in code) to preview?
Example:
How i can pass myCustomDate to DemoView as System Date?
Example:
Code Block struct DemoView_Previews: PreviewProvider { static var previews: some View { let myCustomDate = Date() // just for example return DemoView() } }
How i can pass myCustomDate to DemoView as System Date?
Code Block struct TestView: View { var currentDate: Date var body: some View { Text("Its \(currentDate)") } } struct TestView_Previews: PreviewProvider { static var previews: some View { TestView(currentDate: Date()) } }
May be my english is poor to explain..
i know how to pass a var to my view, for init, or binding, or environmentObject... I want pass a date for preview simulator... so when run my view in the preview the simulator's date will be that date.
i know how to pass a var to my view, for init, or binding, or environmentObject... I want pass a date for preview simulator... so when run my view in the preview the simulator's date will be that date.