swiftui

How to prevent iOS 14 Widget opening app and react to callback

时光毁灭记忆、已成空白 提交于 2021-02-04 07:38:25
问题 So, I already read several blogs, posts, and Apple's own Human Interface Guidelines that iOS 14 Widgets are NOT interactive, BUT: It's possible to pass a short link to the app when pressing on a target. Apple on its own says: "Small Widgets got one single tap target, Medium and Large Widgets got multiple tap targets". OK! Now when you tap on these Targets the app is opening and the Widget is passing that short link to the App. BUT, now my question, where Google says Idk: Can I

SwiftUI: Can't get the transition of a DetailView to a ZStack in the MainView to work

你。 提交于 2021-02-04 06:21:08
问题 I can't find the answer to this anywhere, hopefully one of you can help me out. I have a MainView with some content. And with the press of a button I want to open a DetailView. I am using a ZStack to layer the DetailView on the top, filling the screen. But with the following code I can't get it to work. The DetailView does not have a transition when it inserts and it stops at removal. I have tried with and without setting the zIndex manually, and a custom assymetricalTransition. Couldn't get

SwiftUI: Can't get the transition of a DetailView to a ZStack in the MainView to work

大憨熊 提交于 2021-02-04 06:20:10
问题 I can't find the answer to this anywhere, hopefully one of you can help me out. I have a MainView with some content. And with the press of a button I want to open a DetailView. I am using a ZStack to layer the DetailView on the top, filling the screen. But with the following code I can't get it to work. The DetailView does not have a transition when it inserts and it stops at removal. I have tried with and without setting the zIndex manually, and a custom assymetricalTransition. Couldn't get

How to detect scroll direction programmatically in SwiftUI ScrollView

﹥>﹥吖頭↗ 提交于 2021-02-04 05:47:36
问题 I want display or hide items by scroll direction just like safari. Hide something when scroll up, and show it when scroll down. 回答1: You would use GeometryReader to get the global position of one in the views in the ScrollView to detect the scroll direction. The code below will print out the current midY position. Dependent on the +/- value you could display or hide other views. struct ContentView: View { var body: some View { ScrollView{ GeometryReader { geometry in Text("Top View \(geometry

How to detect scroll direction programmatically in SwiftUI ScrollView

ぃ、小莉子 提交于 2021-02-04 05:46:04
问题 I want display or hide items by scroll direction just like safari. Hide something when scroll up, and show it when scroll down. 回答1: You would use GeometryReader to get the global position of one in the views in the ScrollView to detect the scroll direction. The code below will print out the current midY position. Dependent on the +/- value you could display or hide other views. struct ContentView: View { var body: some View { ScrollView{ GeometryReader { geometry in Text("Top View \(geometry

SwiftUI @State and .sheet() ios13 vs ios14

[亡魂溺海] 提交于 2021-02-03 12:44:10
问题 Hello I am running into a problem here and I do not have a consistent behavior between my .sheet() view when running on ios13 or ios14 I got a view like this : @State private var label: String = "" @State private var sheetDisplayed = false ///Some code var body: some View { VStack { Button(action: { self.label = "A label" self.isDisplayed = true }) { Text("test") } }.sheet(isPresented: $sheetDisplayed, onDismiss: { self.label = "" }) { Text(self.label) } } On ios 13 this work as expected btn

Fullscreen view in watchOS with SwiftUI

对着背影说爱祢 提交于 2021-02-02 03:46:29
问题 I wan't to display a SwiftUI View as fullscreen in watchOS (without the Cancel/Back Button or Clock) I've tried adding a Sprite Kit Scene to the view and also setting the .edgesIgnoringSafeArea(.all) but I'm still able to hide them or put a view under the top bar. 回答1: Unless it's a game, it's not possible to strip out the space at the top, watchOS reserves it so that the time is always visible to the user. 回答2: Turns out it does "work", even with SwiftUI: Using Interface Builder: https:/

Fullscreen view in watchOS with SwiftUI

ε祈祈猫儿з 提交于 2021-02-02 03:44:44
问题 I wan't to display a SwiftUI View as fullscreen in watchOS (without the Cancel/Back Button or Clock) I've tried adding a Sprite Kit Scene to the view and also setting the .edgesIgnoringSafeArea(.all) but I'm still able to hide them or put a view under the top bar. 回答1: Unless it's a game, it's not possible to strip out the space at the top, watchOS reserves it so that the time is always visible to the user. 回答2: Turns out it does "work", even with SwiftUI: Using Interface Builder: https:/

How we can get and read size of a Text with GeometryReader in SwiftUI?

无人久伴 提交于 2021-02-01 20:48:34
问题 I am trying to read the width of my Text depending on size of Text Font, As we know GeometryReader takes all possible given place to him, in this codes it just take himself the given frame size, that I passed it, but it does not take size of my Text! what I am doing Wrong? I what GeometryReader start reading my Text size only! not himself frame width. Here is my code: struct ContentView: View { @State var fontSize: CGFloat = 20.0 var body: some View { Spacer() textWidthGeometryReader(fontSize

How we can get and read size of a Text with GeometryReader in SwiftUI?

女生的网名这么多〃 提交于 2021-02-01 20:45:15
问题 I am trying to read the width of my Text depending on size of Text Font, As we know GeometryReader takes all possible given place to him, in this codes it just take himself the given frame size, that I passed it, but it does not take size of my Text! what I am doing Wrong? I what GeometryReader start reading my Text size only! not himself frame width. Here is my code: struct ContentView: View { @State var fontSize: CGFloat = 20.0 var body: some View { Spacer() textWidthGeometryReader(fontSize