Category "swiftui"

SwiftUI: use Link with onTapGesture

I want to specify a Link in my SwiftUI view, but I also want to register when/if that Link was actually tapped or not. What's the best way to do this? I tried a

Why is my view not updating when value is updated using @Published and @ObservedObject?

I am creating an object recognition app that takes frames from the camera and outputs a description of the image into a text view on the screen. I can print the

How to make search bar in iOS 15 appear by default?

I started to develop an application using iOS15 and the new .searchable modifier. I have a simple layout with some placeholder results on the main page and a se

SwiftUI Segmented Control Customizable

I want to achieve such a control like this (https://github.com/Yalantis/Segmentio) in SwiftUI (but without image): What would be the best approach? Should I us

SwiftUI: ScrollView that drags bottom sheet with it

I'm trying to create a SwiftUI Scrollview that drags its container like this: https://drive.google.com/file/d/1O92DgsVI1OjM1HEUXUwVywB8gcdShOP-/view?usp=sharing

How to show only the result of a searchable of a List Swiftui

I'm donig a list numbers but i want to show only the result of my searchable not the whole list, how can i hide the list? I was trying to change the state of a

Customisable SwiftUI Refresh spinner

I currently have a simple SwiftUI ScrollView that contains a single element. I have added the .refreshable(action: ) property to allow (pull down) refreshing of

Tappable portions within a string for SwiftUI

I'm trying to add tappable segments to a Text and I have most of it but I cannot make an array of Texts with .onTapGestures. How can I add the tap gestures to

SwiftUI calculate coordinate of the corner of UIimage

I'm looking to find the correct coordinate x,y of the 4 corners of the image display in the view. I wrote this code.. to calculate the first top left corner coo

SwiftUI Custom Picker Label Not Rendering

After updating to iOS 15 and Xcode 13, my picker in my app is no longer showing a custom label. Running the app on an iOS 14 device, the pickers render fine. Th

Vibrate after a button is clicked (x) amount of times

As the title says i am trying to trigger a vibration when the button is clicked x amount of times. For example when the button is clicked 3 times I want a vibra

SwiftUI List row color inconsistent while scrolling in a NavigationView

The background color of row views within a List inside a NavigationView inconsistently switch from transparent to white as I scroll.

Updating @Published var if a userdefault value is present swift

I am trying to check my app and see if a value exists in user defaults and if it does exist they will be taken into the app. If it doesnt exist they need to ent

SwiftUI Picker not changing bounded value - is binding ok?

I have a view with @State var myTask:MyTask let priorities = ["","A","B","C","D","E","F","G","H","I","J","K"] var body: some View{ VStack{ Picke

Is there a way to check if @Environmentobject exists swiftui

I have a view hierarchy where sometimes there is a chance that an @EnvironmentObject is not resolved. Is there a way to check if such @EnvironmentObject exists

Get coordinates in real time of a moving view in SwiftUI

I am moving a view called Point (which is basically a point), the point is moving in the screen every 2 seconds, and I need to update the coordinates in real ti

Why is there a Gap between VStacks in SwiftUI?

A whiteness is seen in the area drawn with the red line. If I change the background color of the most inclusive Vstack, that white area changes. Deleting spacer

Change the mapType to .satellite etc with a picker

I want to be able to change the mapType from .standard to .satellite and .hybrid in xCode 13.3 Can anybody tell me if it is at all possible with this code? I im

SwiftUI - proper use of @available() and #available

Am I missing something in the following code? This app builds (macOS Monterey b5 / Xcode 13 b5) and executes perfectly on an iOS 15 device -- but causes a SIGAB

Long Press Gesture Recognizer location(in: view) not correctly calculating location

I'm using a UIScrollView to display an image with various markers on top. The image view has a UILongPressGestureRecognizer that detects long presses. When the