swiftui

Create a NavigationLink without back button SwiftUI

拈花ヽ惹草 提交于 2020-12-30 08:14:58
问题 Im trying to link a button action in SomeView1() to navigate to a someView2() without having the back button at the top of the screen. Instead, I want to add another button in SomeView2() that will navigate back to SomeView1(). is this possible in SwiftUI yet? SomeView1() struct SomeView1: View { var body: some View { NavigationView { VStack { //...view's content NavigationLink(destination: SomeView2()) { Text("go to SomeView2") } Spacer() } } } } SomeView2() struct SomeView2: View { var body

Create a NavigationLink without back button SwiftUI

泄露秘密 提交于 2020-12-30 08:13:45
问题 Im trying to link a button action in SomeView1() to navigate to a someView2() without having the back button at the top of the screen. Instead, I want to add another button in SomeView2() that will navigate back to SomeView1(). is this possible in SwiftUI yet? SomeView1() struct SomeView1: View { var body: some View { NavigationView { VStack { //...view's content NavigationLink(destination: SomeView2()) { Text("go to SomeView2") } Spacer() } } } } SomeView2() struct SomeView2: View { var body

Create a NavigationLink without back button SwiftUI

混江龙づ霸主 提交于 2020-12-30 08:13:35
问题 Im trying to link a button action in SomeView1() to navigate to a someView2() without having the back button at the top of the screen. Instead, I want to add another button in SomeView2() that will navigate back to SomeView1(). is this possible in SwiftUI yet? SomeView1() struct SomeView1: View { var body: some View { NavigationView { VStack { //...view's content NavigationLink(destination: SomeView2()) { Text("go to SomeView2") } Spacer() } } } } SomeView2() struct SomeView2: View { var body

Create a NavigationLink without back button SwiftUI

心已入冬 提交于 2020-12-30 08:13:34
问题 Im trying to link a button action in SomeView1() to navigate to a someView2() without having the back button at the top of the screen. Instead, I want to add another button in SomeView2() that will navigate back to SomeView1(). is this possible in SwiftUI yet? SomeView1() struct SomeView1: View { var body: some View { NavigationView { VStack { //...view's content NavigationLink(destination: SomeView2()) { Text("go to SomeView2") } Spacer() } } } } SomeView2() struct SomeView2: View { var body

Create a NavigationLink without back button SwiftUI

放肆的年华 提交于 2020-12-30 08:12:43
问题 Im trying to link a button action in SomeView1() to navigate to a someView2() without having the back button at the top of the screen. Instead, I want to add another button in SomeView2() that will navigate back to SomeView1(). is this possible in SwiftUI yet? SomeView1() struct SomeView1: View { var body: some View { NavigationView { VStack { //...view's content NavigationLink(destination: SomeView2()) { Text("go to SomeView2") } Spacer() } } } } SomeView2() struct SomeView2: View { var body

SwiftUI List inside ScrollVIew

删除回忆录丶 提交于 2020-12-30 05:57:23
问题 I want to make my List inside a ScrollView so that I can scroll List rows and headers together. But I found that List inside ScrollView isn't working. It shows nothing. Anyone know why this happens and(or) how to fix? I should use both of them. I should use ScrollView so that I can make my header(image or text) also scrolled when I scroll the rows. I should use List to use .ondelete() method. my sample code is below. @State private var numbers = [1,2,3,4,5,6,7,8,9] var body: some View {

SwiftUI .rotationEffect() framing and offsetting

自闭症网瘾萝莉.ら 提交于 2020-12-30 05:48:10
问题 When applying .rotationEffect() to a Text, it rotates the text as expected, but its frame remains unchanged. This becomes an issue when stacking rotated views with non-rotated views, such as with a VStack of HStack, causing them to overlap. I initially thought the rotationEffect would simply update the frame of the Text to be vertical, but this is not the case. I've tried manually setting the frame size and (if needed, offsetting) the Text, which sort of works, but I don't like this solution

SwiftUI - Detect when ScrollView has finished scrolling?

南楼画角 提交于 2020-12-30 02:21:47
问题 I need to find out the exact moment when my ScrollView stops moving. Is that possible with SwiftUI? Here would be an equivalent for UIScrollView . I have no idea after thinking a lot about it... A sample project to test things out: struct ContentView: View { var body: some View { ScrollView { VStack(spacing: 20) { ForEach(0...100, id: \.self) { i in Rectangle() .frame(width: 200, height: 100) .foregroundColor(.green) .overlay(Text("\(i)")) } } .frame(maxWidth: .infinity) } } } Thanks! 回答1:

SwiftUI - Detect when ScrollView has finished scrolling?

一曲冷凌霜 提交于 2020-12-30 02:21:13
问题 I need to find out the exact moment when my ScrollView stops moving. Is that possible with SwiftUI? Here would be an equivalent for UIScrollView . I have no idea after thinking a lot about it... A sample project to test things out: struct ContentView: View { var body: some View { ScrollView { VStack(spacing: 20) { ForEach(0...100, id: \.self) { i in Rectangle() .frame(width: 200, height: 100) .foregroundColor(.green) .overlay(Text("\(i)")) } } .frame(maxWidth: .infinity) } } } Thanks! 回答1:

SwiftUI UIViewRepresentable UITextView Binding

大兔子大兔子 提交于 2020-12-29 16:56:42
问题 Multiline text input is currently not natively supported in SwiftUI (hopefully this feature is added soon!) so I've been trying to use the combine framework to implement a UITextView from UIKit which does support multiline input, however i've been having mixed results. This is the code i've created to make the Text view: struct MultilineTextView: UIViewRepresentable { @Binding var text: String func makeUIView(context: Context) -> UITextView { let view = UITextView() view.isScrollEnabled =