Skip to content

Instantly share code, notes, and snippets.

extension DateFormatter {
static var exifDateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy':'MM':'dd' 'HH':'mm':'ss'.'SSS"
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone.current
return formatter
}()
}
@paulhimes
paulhimes / OnLayout Tutorial 01.swift
Last active March 9, 2021 02:02
OnLayout Tutorial 01
struct MainView: View {
var body: some View {
ScrollView {
HStack {
Spacer()
Text("ScrollView Content")
.multilineTextAlignment(.center)
.foregroundColor(.white)
.background(Color.blue.brightness(0.2))
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 02.swift
Last active March 9, 2021 02:03
OnLayout Tutorial 02
struct MainView: View {
var body: some View {
ScrollView {
HStack {
Spacer()
Text("ScrollView Content")
.multilineTextAlignment(.center)
.foregroundColor(.white)
.background(Color.blue.brightness(0.2))
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 03.swift
Last active March 9, 2021 02:03
OnLayout Tutorial 03
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 04.swift
Last active March 9, 2021 02:03
OnLayout Tutorial 04
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 05.swift
Last active March 9, 2021 02:04
OnLayout Tutorial 05
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 06.swift
Last active March 9, 2021 02:04
OnLayout Tutorial 06
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 07.swift
Last active March 9, 2021 02:04
OnLayout Tutorial 07
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 08.swift
Last active March 9, 2021 02:05
OnLayout Tutorial 08
struct MainView: View {
/// Controls the amount of padding above the scroll view's
/// content.
@State var titleBarHeight: CGFloat = 123
var body: some View {
ScrollView {
HStack {
Spacer()
@paulhimes
paulhimes / OnLayout Tutorial 09.swift
Last active March 9, 2021 02:23
OnLayout Tutorial 09
func layoutWatcher(_ proxy: GeometryProxy) -> some View {
/// This updates the height after each time the view
/// is updated.
DispatchQueue.main.async {
titleBarHeight = proxy.size.height
}
return Color.clear
.onAppear {
/// This updates the height when the view first
/// appears.