Category "swiftui"

SwiftUI - How to pass EnvironmentObject into View Model?

I'm looking to create an EnvironmentObject that can be accessed by the View Model (not just the view). The Environment object tracks the application session da

How do I render a SwiftUI View that is not at the root hierarchy as a UIImage?

Suppose I have a simple SwiftUI View that is not the ContentView such as this: struct Test: View { var body: some View { VStack {

Swiftui - How do I initialize an observedObject using an environmentobject as a parameter?

I'm not sure if this is an antipattern in this brave new SwiftUI world we live in, but essentially I have an @EnvironmentObject with some basic user information

Mutable Binding in SwiftUI Live Preview

I have a ChildView with a variable: @Binding var itemName: String In this ChildView I have few buttons that change value of the variable: Button(action: {

SwiftUI - navigationBarBackButtonHidden - swipe back gesture?

if I set a custom Back Button (which everyone wants, hiding the ugly text ;-) ) and using .navigationBarBackButtonHidden, the standard Swipe Back gesture on the

Function opaque return type was inferred as ... which defines the opaque type in terms of itself

Xcode gives the error: Function opaque return type was inferred as 'Button', which defines the opaque type in terms of itself on the line below: @State var sh

Mimic the iOS Photos APP browsing behavior with SwiftUI

I am new to SwiftUI (iOS development). I would like to mimic the iOS Photos APP browsing behavior with SwiftUI. More specifically, I want to display a photo in

onAppear is causing problem with the preview but no error is shown

self learning beginner here. When I remove .onAppear{add()}, the preview works fine. I tried to attach it to other the body view, the Vstack but it causes anot

SwiftUI view layouts with frame maxHeight and .infinity

How to layout views in SwiftUI in such way I have input fields that I want to stretch to fill available space This inputs are placed in VStack in such way th

iOS Swift Combine: cancel a Set<AnyCancellable>

If I have stored a cancellable set into a ViewController: private var bag = Set<AnyCancellable>() Which contains multiple subscription. 1 - Should I canc

How do I read a User's Firestore Map to a Swift Dictionary?

I have my user struct with has a dictionary of all their social medias. struct User: Identifiable { var id: String { uid } let uid, email, name, bio, profileI

How to give shadow with cornerRadius to a Button in SwiftUI

I'm trying to give a shadow to Button using following code. Code: Button(action: { }) { Text("SIGN IN") .fon

SwiftUI Calling functions from other class

I am having a little trouble here: I have a class class TempC { func GetData(){ //do stuff } } And in ContentView I want to call the func

CoreData .FileExporter creates endless local backup of sqlite file on MacOS

I want to create a local backup of the CoreData sqlite file, and then have the user choose the save location with a popup. I've attached the following fileExpor

How to implement localization in Swift UI

Can anybody help me? I can't find any description of the localization in Swift UI. Can anyone please give advice or better an example of how to localize for exa

How to use UIAccessibility.post(notification: .layoutChanged, argument: nil) in SwiftUI to move focus to specific view

I have one button on screen and on that button tap it opens one modal (view). but after closing that view, the focus of accessibility voice over goes on top of

SwiftUI - create a single dashed line with SwiftUI

I need to create a single dashed line. I tried going about it by creating a Rectangle view with a dashed stroke. However, when setting the height of the rectang

How to style rows in SwiftUI List on WatchOS?

I'm working with SwiftUI and is trying to make a list of buttons with custom .buttonStyle inside a List view on WatchOS, but can't get it to work. Is this even

Repeating animation on SwiftUI Image

Given the following struct: struct PeopleList : View { @State var angle: Double = 0.0 @State var isAnimating = true var foreverAnimation: Animatio

Using @EnvironmentObject properly

I am just trying to get my updated value to display in my application after it receives a new value from bluetooth core. I know the value in the class is updati