Category "swiftui"

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

How to consecutively present two alert views using SwiftUI

I want to immediately present the second alert view after click the dismiss button of the first alert view. Button(action: { self.alertIsVisible = true })

How to popup a document picker in ios and macos using catalyst

I'm trying to popup a document picker using mac catalyst, but all I get is a blank screen. All works well on ios 13.2.2 on iPad and iPhone, but not on macos 10

UIDocumentPickerViewController doesn't show any contents on Mac Catalyst

UIDocumentPickerViewController works on iOS but not on Mac Catalyst. Is there any alternatives to workaround this issue? BTW, NSOpenPanel is unavailable on Mac

Using user input in SwiftUI to perform calculations

I'm making a school project in which I have to find the weight of a person on different planets, but I am confused about how I should use the input and multiply

SwiftUI animation not working using animation(_:value:)

In SwiftUI, I've managed to make a Button animate right when the view is first drawn to the screen, using the animation(_:) modifier, that was deprecated in mac

SwiftUI overlay cancels touches

I have a button and I'd like to put a semi-transparent gradient overlay on top of it. Button(action: { print("Pressed") }) { Text("Press me") } .overlay(

SwiftUI display gif image

The way to display animated gif image in swiftUI because of Image Image("fall-leaves") does not support gifs answer below

Clickable area of SwiftUI Picker overlapping

I am currently trying to create a page with three adjacent Picker views inside of an HStack as seen below: I made a CustomPicker view where I limit the frame t

SwiftUI Widget: 'main' attribute can only apply to one type in a module

I've created a Widget and I'm adding @main on top of the declaration. However, when I switch to the Widget extension target and run it, I get the error 'main' a

SwiftUI strange behavior when moving items between sections in a List

so I've been trying to make a component using swiftUI that allows you to move items in a List between sections. I prepared an example with two sections: "First

ADA - Programmatically shifting VoiceOver focus to another SwiftUI view - compatible with IOS 13+

Overview: I'm having difficulty understanding how to properly programmatically shift accessibility focus in a SwiftUI view compatible with IOS 13+. This means u