Category "swiftui"

SwiftUI: Sheet cannot show correct values in first time

I found strange behavior in SwiftUI. The sheet shows empty text when I tap a list column first time. It seems correct after second time. Would you help me? impo

SwiftUI hiding navigation bar affects other animations

I have the following SwiftUI view and I want to have it repeat the scale animation to simulate a pulsing effect. However, in addition to the scaling, the circle

Why does binding to the Picker not work anymore in swiftui?

When I run a Picker Code in the Simulator or the Canvas, the Picker goes always back to the first option with an animation or just freezes. This happens since l

How to display an int without commas?

I have a list of Text views that include a year saved as an int. I'm displaying it in an interpolated string: Text("\($0.property) \($0.year) \($0.etc)") The p

UIHostingController and navigationController

Default swift project with view controller embedded in navigationController and pushing to next UIHostingController. How to call navigationController?.popViewC

Error message: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeead03e18)

I'm creating an app and I get this error: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeead03e18). Whole code runs without any errors, it's just when I try to

SwiftUI TextField binding to Double not working with custom Formatter

I have a Binding to a Double parameter that is set by a SwiftUI TextField. I use a custom Formatter that converts to and from a Double value. The TextField

SwiftUI: Translucent background for fullScreenCover

So technically I want to show a loading screen view. I'm using fullScreenCover. struct ContentView: View { @State private var isLoading = false

Change GroupBox background color in SwiftUI

How can I change the default gray background color of a GroupBox view in SwiftUI? I tried adding a background modifier, but this just changes the white backgrou

ToolbarItemGroup in .toolbar {} doesn't work in a Sheet

I'm using SwiftUI 3.0, Swift 5.5 and Xcode 13.2, tested on iOS 15.3 iPhone device, and iOS 15.2 iPhone simulator. I have tested the following. This is a view, w

SwiftUI .onTapGesture always higher priority than .swipeActions

How do I make my the code in .swipeActions be called instead of the one in .onTapGesture? I have a SwiftUI view like follows: struct ContentView: View {

Xcode 11 beta swift ui preview not showing

Just playing with Swift UI basic app and the preview canvas is not showing even though I'm in canvas mode. App runs, and I have this little snippet what am I mi

There doesn't appear to be support for UITabBar in SwiftUI. Workarounds?

SwiftUI doesn't appear to support UITabBar. How can I integrate that capability? Merely wrapping the view like one would a (eg) MKMapView, doesn't work because

How to change "Cancel" button text in modal sheet view in SwiftUI on watchOS 7?

I have 2 simple views: import SwiftUI struct ContentView: View { @State private var showingModalView = false var body: some View { Button(

Duplicate toolbar in SwiftUI

I added toolbar to 2 text fields, but the toolbar shows up twice: This is the code for my custom text field: public struct SUIDecimalField: View { public var

Custom back button for NavigationView's navigation bar in SwiftUI

I want to add a custom navigation button that will look somewhat like this: Now, I've written a custom BackButton view for this. When applying that view as l

How to print() to Xcode console in SwiftUI?

So I tried to put a print statement while debugging in a SwiftUI View. print("landmark: \(landmark)") In the following body. var body: some View { Navig

iOS SwiftUI: pop or dismiss view programmatically

I couldn't find any reference about any ways to make a pop or a dismiss programmatically of my presented view with SwiftUI. Seems to me that the only way is to

What is the difference between ObjectBinding and EnvironmentObject?

What is the purpose of @EnvironmentObject when we have @Binding property wrapper ? I am having trouble figuring out why @EnvironmentObject is needed. I took a l

Pull down to refresh data in SwiftUI

i have used simple listing of data using List. I would like to add pull down to refresh functionality but i am not sure which is the best possible approach. Pu