Category "swiftui"

NavigationView in iPad popover does not work properly in SwiftUI

I have the following code that displays a popover when a button is tapped: struct ContentView: View { @State private var show = false var body: some

set @State var inside geometryReader

How is it possible to set a @State var inside a geometryReader? This is my code: @State var isTest:Int = 0 var body: some View { VStack{ ForEach(se

Placing the toggle sidebar button on the sidebar toolbar

I have a three column layout macOS application with the first being the sidebar. I have a button that toggles that enabling the user to hide the sidebar. On Xco

Crash when deleting an item from List in SwiftUI with custom RandomAccessCollection

Basic approach I am currently tring to clean up my Core Data/SwiftUI code, and part of that is moving code out of my Views and into my ViewModels. Since it seem

How to disable SwiftUI animations in UITests?

I tried to disable animation in UITests with the following code: let app = XCUIApplication() app.launchEnvironment = ["DISABLE_ANIMATIONS": "1"] I also tried

SwiftUI EnvironmentObject not available in View initializer?

I passed the environmentObject appSettings into my view successfully. I can use it to modify my font and the picker in my View. But if I try to access an envir

Change a rotation of AnchorEntity in RealityKit

I placed 3d object to ARViewController after 3 seconds of placing object, then I want to rotate object by 90 degrees: arView.scene.addAnchor(anchorEntity) Disp

SwiftUI dragging ScrollView flickers as the keyboard is dismissing

When I develop the feature that allows users drag ScrollView to dismiss keyboard in SwiftUI, I find that if you drag ScrollView as the keyboard is dismissing, t

How to move a model and generate its collision shape at the same time?

I have ModelEntity in SwiftUI and it moves. But the problem is: when adding generateCollisionShape method, it doesn't move anymore. I want a collision effect as

SwiftUI customized text field in OSX

I am creating a edit view in SwiftUI for Mac OSX. A user can change his profile. At the moment I am using default Text() elements to view his current values/set

How to make exponents in the SwiftUI

I found the new method in SwiftUI to allow you to create an exponent. Here what I write code is based in SwiftUI on the Swift Playground. import SwiftUI impo

SwiftUI on macOS - handle single-click and double-click at the same time

Consider this view in SwiftUI: struct MyView: View { var body: some View { Rectangle() .fill(Color.blue) .frame(width: 200,

SwiftUI on macOS - handle single-click and double-click at the same time

Consider this view in SwiftUI: struct MyView: View { var body: some View { Rectangle() .fill(Color.blue) .frame(width: 200,

SwiftUI iOS - how to capture hardware key events

I’m new to iOS development. Following a tutorial I have created a simple calculator using SwiftUI. I have a keyboard attached to my iPad, and I would lik

How to assign default modifiers to a SwiftUI view?

I'm trying to make reusable custom views that themselves can be customized later. Ideally I'd be able to define default modifiers like Color, Font, etc that the

SwiftUI: how to remove spacing around Text()?

As example I have 3 properties: var path1FilePath:String = "Src/" var path2FileName: String = "filename" var path3Extension: String = ".jpg" I need to displa

How to using realtime camera streaming in swiftui?

I build a StreamingView like this: struct StreamingView: UIViewRepresentable { func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<

How to give DatePicker a minute interval in SwiftUI

does anyone know how to give the minutes DatePicker an interval? I am trying to only display multiples of 15 (0, 15, 30, 45). Is this only yet possible by inter

SwiftUI: transform Binding into another Binding

Is there a way to e.g. logically negate Binding<Bool>? For example, I've a state variable @State var isDone = true which I pass as a biding into diffe

DragGesture on a VStack with lot of Buttons, how to detect when the drag is inside a Button

In UIKit this could be done with code like this: if button.frame.contains(sender.location(in: rightStackView)) { ... } but in SwiftUI I can't seem to find an