swiftui

Spacing between sections in a form

爷,独闯天下 提交于 2021-01-01 08:50:30
问题 Is it possible to adjust the spacing between section blocks in a form? Ive tried using .padding() but it only moves whatever is inside the section, not the actual section itself. 回答1: Try a spacer between the sections: Spacer(minLength: CGFloat?) 回答2: You can try this property without giving float value too Spacer() // this will work 来源: https://stackoverflow.com/questions/60143989/spacing-between-sections-in-a-form

Spacing between sections in a form

↘锁芯ラ 提交于 2021-01-01 08:50:11
问题 Is it possible to adjust the spacing between section blocks in a form? Ive tried using .padding() but it only moves whatever is inside the section, not the actual section itself. 回答1: Try a spacer between the sections: Spacer(minLength: CGFloat?) 回答2: You can try this property without giving float value too Spacer() // this will work 来源: https://stackoverflow.com/questions/60143989/spacing-between-sections-in-a-form

SwiftUI: ForEach in Picker doesn't update

▼魔方 西西 提交于 2021-01-01 08:46:10
问题 I have an array of elements, from which I want to chose one using Picker , and I have a Button which simply adds a new element to the array. The thing is, when I add an element, the Picker choices are not updated. It doesn't work with DefaultPickerStyle , but works with SegmentedPickerStyle . The code: import SwiftUI struct ExampleView: View { @State var array : Array<Int> = [Int]() @State var selection : Int = 0 var body: some View { VStack { Picker("", selection: self.$selection) { ForEach

How do I intercept link navigation when using WKWebView in SwiftUI?

不羁的心 提交于 2021-01-01 07:53:38
问题 I'm using WKWebView in a SwiftUI app. I have an HTML file in my bundle that I'm initially loading into the WKWebView. The file has a link in it that I would like to open in an external browser if tapped. I've created the WKWebView using the following code: import SwiftUI import WebKit struct WebView: UIViewRepresentable { typealias UIViewType = WKWebView let request: URLRequest func makeUIView(context: UIViewRepresentableContext<WebView>) -> WKWebView { let webView = WKWebView() let delegate

How to wrap Text around some view in a HStack?

▼魔方 西西 提交于 2021-01-01 07:14:44
问题 I wanted to ask if following scenario would be possible and if yes how I could approach the problem. The following code produces the attached image: HStack(alignment: .firstTextBaseline) { ZStack { RoundedRectangle(cornerRadius: 5) .foregroundColor(Color(UIColor.secondarySystemFill)) Text("Test") .clipShape(RoundedRectangle(cornerRadius: 5)) .foregroundColor(.secondary) .layoutPriority(1) .padding(.all, 5) } Text("This is a very long message with more words than one line can handle bla blabla

How to wrap Text around some view in a HStack?

自古美人都是妖i 提交于 2021-01-01 07:14:36
问题 I wanted to ask if following scenario would be possible and if yes how I could approach the problem. The following code produces the attached image: HStack(alignment: .firstTextBaseline) { ZStack { RoundedRectangle(cornerRadius: 5) .foregroundColor(Color(UIColor.secondarySystemFill)) Text("Test") .clipShape(RoundedRectangle(cornerRadius: 5)) .foregroundColor(.secondary) .layoutPriority(1) .padding(.all, 5) } Text("This is a very long message with more words than one line can handle bla blabla

How to wrap Text around some view in a HStack?

对着背影说爱祢 提交于 2021-01-01 07:14:24
问题 I wanted to ask if following scenario would be possible and if yes how I could approach the problem. The following code produces the attached image: HStack(alignment: .firstTextBaseline) { ZStack { RoundedRectangle(cornerRadius: 5) .foregroundColor(Color(UIColor.secondarySystemFill)) Text("Test") .clipShape(RoundedRectangle(cornerRadius: 5)) .foregroundColor(.secondary) .layoutPriority(1) .padding(.all, 5) } Text("This is a very long message with more words than one line can handle bla blabla

View presented twice in SwiftUI on iOS 14

天大地大妈咪最大 提交于 2021-01-01 06:52:05
问题 I need to dynamically present views based on a model so the decision of which view to present and the creation of the views needs to be external to the SwiftUI views. This is working well on iOS 13 but on iOS 14 the first view presents again instead of the second view, although the second view does get initialised as expected the first view is pushed onto the navigation stack a second time. It seems like a iOS 14 bug but perhaps I'm doing something wrong so asking here before filing a bug

SwiftUI: Updating an array item does not update the child UI immediately

て烟熏妆下的殇ゞ 提交于 2021-01-01 04:24:29
问题 I have an array of items (numbers) to be presented to the user using NavigationView, List and a leaf page. When I update an item (numbers[index] = ...) on a leaf page, it updates the list correctly (which I see when I go back to the list), but not the leaf page itself immediately. I see the change if I go back to the list and re-open the same leaf page. I would like to understand why it does not update the UI immediately, and how to fix it. Here is the simplified code to re-produce this

SwiftUI: Updating an array item does not update the child UI immediately

被刻印的时光 ゝ 提交于 2021-01-01 04:23:40
问题 I have an array of items (numbers) to be presented to the user using NavigationView, List and a leaf page. When I update an item (numbers[index] = ...) on a leaf page, it updates the list correctly (which I see when I go back to the list), but not the leaf page itself immediately. I see the change if I go back to the list and re-open the same leaf page. I would like to understand why it does not update the UI immediately, and how to fix it. Here is the simplified code to re-produce this