swiftui

SwiftUI: Stepper Binding is not working in the subview

故事扮演 提交于 2021-02-11 15:12:35
问题 I have a stepper control in the main list view as well as in the detail view. the code is exactly the same. However the stepper in main view is working perfectly, but the subview is stopping after 1 increment (as it looks like the upper bound is set.) The funny thing is it was working some time ago, after improvements, i am not able to trace what exactly changed it s behaviour. Here is the code. struct QuestionCardTest: View { @Binding var question : SurveyQuestion var body: some View {

SwiftUI: Stepper Binding is not working in the subview

可紊 提交于 2021-02-11 15:08:33
问题 I have a stepper control in the main list view as well as in the detail view. the code is exactly the same. However the stepper in main view is working perfectly, but the subview is stopping after 1 increment (as it looks like the upper bound is set.) The funny thing is it was working some time ago, after improvements, i am not able to trace what exactly changed it s behaviour. Here is the code. struct QuestionCardTest: View { @Binding var question : SurveyQuestion var body: some View {

Animate view to fullscreen (Card to detail)

大憨熊 提交于 2021-02-11 14:46:23
问题 Im trying to replicate the cards from the Appstore's today tab: https://imgur.com/a/1Jd4bI5 This is what I have so far: struct ContentView: View { @State var showDetail = false @State var selectedForDetail : Post? var posts = [...] // Just sample data: Post(subtitle: "test1", title: "title1", extra: "Lorem ipsum dolor...") etc. var body: some View { ZStack { ScrollView{ ForEach(self.posts){ current in PostView(post: current, isDetailed: self.$showDetail).onTapGesture { self.selectedForDetail

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

Override menu button label text color (MacOS SwiftUI)

我与影子孤独终老i 提交于 2021-02-11 14:23:34
问题 Can I override a Menu button label's "post-set dimmed" color? The GIF below shows a legibly bright menu item that dims after new selection. (Default behavior for this system style (e.g., in trackpad prefs). But it fails accessibility standards, such as WCAG's requirement for > 4.5 : 1 luminance contrast for that font size in an active control (system default is ~ 2). I've tried: setting accentColor and foregroundColor everywhere using onChange to update an @State color fed into the

“value of type ____ has no member 'help' ” after update to latest stable XCode release

徘徊边缘 提交于 2021-02-11 14:21:55
问题 MacOS: 11.0 Beta (20A5384c) Xcode: 12.0.1 (12A7300) After update from Xcode beta to release version I see lot of errors like: "value of type ____ has no member 'help' " Is it was deprecated from release build of Xcode 12 ? On the XCode 12 beta works well. 来源: https://stackoverflow.com/questions/64148126/value-of-type-has-no-member-help-after-update-to-latest-stable-xcode-r

“value of type ____ has no member 'help' ” after update to latest stable XCode release

最后都变了- 提交于 2021-02-11 14:20:20
问题 MacOS: 11.0 Beta (20A5384c) Xcode: 12.0.1 (12A7300) After update from Xcode beta to release version I see lot of errors like: "value of type ____ has no member 'help' " Is it was deprecated from release build of Xcode 12 ? On the XCode 12 beta works well. 来源: https://stackoverflow.com/questions/64148126/value-of-type-has-no-member-help-after-update-to-latest-stable-xcode-r

SwiftUI - destination of NavigationLink creates view with extra space

天大地大妈咪最大 提交于 2021-02-11 14:15:03
问题 I've whittled my login page down to a single NavigationLink that leads to a List view as its destination. The problem, as you can see in the image below, is that instead of the nicely spaced title on the left, I get the huge space as shown on the right. Both views are the same, but the one on the right is the preview of the page as it was designed. The image on the left is the preview of the page after coming from the login screen. struct ContentView: View { var body: some View {

Why does `Color.` used as aSwiftUI ZStack background not update on TabView on a real device?

爱⌒轻易说出口 提交于 2021-02-11 14:14:06
问题 This code appears to work very well on the canvas preview, but on my real device, sometimes the background color does not update. When switching tabs, the color from the former view remains although the rest of the view is fine. What gives? Here is the main tab view: import SwiftUI struct ContentView: View { @EnvironmentObject var isModalVisible: CustomModal @ObservedObject var modal = CustomModal() var body: some View { ZStack { TabView { ZStack { Color.pink.opacity(0.2) Button(action: {

SwiftUI - destination of NavigationLink creates view with extra space

♀尐吖头ヾ 提交于 2021-02-11 14:12:52
问题 I've whittled my login page down to a single NavigationLink that leads to a List view as its destination. The problem, as you can see in the image below, is that instead of the nicely spaced title on the left, I get the huge space as shown on the right. Both views are the same, but the one on the right is the preview of the page as it was designed. The image on the left is the preview of the page after coming from the login screen. struct ContentView: View { var body: some View {