geometryreader

How to keep Text as leading alignment after set Text().frame(maxWidth: .infinity)

纵然是瞬间 提交于 2021-02-11 14:45:24
问题 It could be a simple case, but I couldn't find a solution. Here is my code , using the GeometryReader to set the relative layout of SwiftUI view size like Image. The issue in on the last VStack, I want to background of Text to go to the right end of VStack. Thus, I set it as Text("Haibo: asdasd").frame(maxWidth: .infinity) but after that I found the text became to horizontal centered and not followed the VStack alignment: .leading. import SwiftUI struct ContentView: View { var body: some View

SwiftUI: Why is the height of proxy.safeAreaInsets.bottom equal to keyboardHeight?

核能气质少年 提交于 2021-02-10 20:13:11
问题 So the safeAreaInset.bottom on the iPhone 11 Pro Max is 34.0, but when the keyboard is open, it changes the safeAreaInset.bottom to the height of the keyboard (346.0 points). Is there any way to access the safeAreaInset.bottom value (34.0) when the keyboard is open? For reference, my content view has a geometry reader in it: var body: some View { GeometryReader { proxy in //I pass in proxy into views in here and then access the safe area with proxy.safeAreaInsets.bottom } } I also need this

SwiftUI: Build View from bottom alignment in scrollView

泄露秘密 提交于 2021-02-10 13:12:01
问题 Is there a way to build UI elements in SwiftUI inside scroll view with bottom Alignment? My use case: I have a screen where the screen has Spacer ( What ever is left after allocating below elements ) LogoView Spacer() - 30 Some Text - 4/5 lines Spacer() - 50 (this will be calculated off of GR size Height) HStack with Two Button - This should be pinned to bottom of view / ScrollView I would like to know how Can I pin the HStack view to ScrollView Bottom I've replicated my setup and reproduced

SwiftUI: Build View from bottom alignment in scrollView

ぐ巨炮叔叔 提交于 2021-02-10 13:05:09
问题 Is there a way to build UI elements in SwiftUI inside scroll view with bottom Alignment? My use case: I have a screen where the screen has Spacer ( What ever is left after allocating below elements ) LogoView Spacer() - 30 Some Text - 4/5 lines Spacer() - 50 (this will be calculated off of GR size Height) HStack with Two Button - This should be pinned to bottom of view / ScrollView I would like to know how Can I pin the HStack view to ScrollView Bottom I've replicated my setup and reproduced

why is VStack not working in GeometryReader with scrollview?

旧时模样 提交于 2021-02-10 06:09:51
问题 My scrollview with vStack worked (in AppleTV - i did not test in iOS) without GeometryReader. Then i added the geometryreader and the VStack "collapses" like a ZStack. What can i do to solve this? (and yes, i need the geometryreader ;)) struct ContentView: View { @State var offset : CGFloat = 0 var body: some View { ScrollView(.vertical, showsIndicators: false) { VStack(alignment: .leading) { GeometryReader { geometry -> AnyView in let newOffset = geometry.frame(in: .global).minY if newOffset

SwiftUI: PreferenceKey is not called when parent view is embedded in NavigationView

江枫思渺然 提交于 2021-02-08 09:15:52
问题 DynamicScalingView is a child view with two buttons designed to have equal width & height using preferencekey Issue: When DynamicScalingView is embedded in NavigationView it not longer adapts to intrinsic and increases its frame size. Current implementation without Navigation works fine but would like to understand how to fix this issue when embedded in NavigationView Uncomment NavigationView in sample view to reproduce the issue DynamicScalingView should adapt to Dynamic font size and

SwiftUI: How to find the height of an image and use it to set the size of a frame

对着背影说爱祢 提交于 2021-01-29 08:34:04
问题 So I've been trying to figure out how to find the height of an image in SwiftUI for a while now with no success. Essentially I have portrait/landscape images, which the portrait ones I want to display at about 600 pt tall, whereas the landscape images I want to display so the width of the image is used, so the height is whatever. That being said, I'm wanting it inside of a GeometryReader, as the offset I am using uses it so that when you scroll down, the image doesn't scroll, but if you

SWiftUI anchorPreference inside List

﹥>﹥吖頭↗ 提交于 2021-01-04 06:06:32
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var

SWiftUI anchorPreference inside List

妖精的绣舞 提交于 2021-01-04 06:01:28
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var

SWiftUI anchorPreference inside List

馋奶兔 提交于 2021-01-04 06:00:29
问题 I'm using anchorPreferences to set the height of GeometryReader to fit the height of its content. The issue I'm experiencing is, after scrolling up and down the List a few times, the app freezes, the design gets messy, and I get the following message in the console: Bound preference CGFloatPreferenceKey tried to update multiple times per frame. Any ideas how I can fix this? IMPORTANT NOTE: I've simplified my design as much as I could. Here is the code: struct ListAndPreferences: View { var