This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LayoutActionModifier: ViewModifier { | |
/// This action is run after each time the view changes. | |
let action: ((GeometryProxy) -> Void)? | |
func body(content: Content) -> some View { | |
content | |
.background( | |
GeometryReader { proxy in | |
layoutWatcher(proxy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MainView: View { | |
var body: some View { | |
ScrollView { | |
HStack { | |
Spacer() | |
Text("ScrollView Content") | |
.multilineTextAlignment(.center) | |
.foregroundColor(.white) | |
.background(Color.blue.brightness(0.2)) | |
Spacer() |
NewerOlder