Category "swiftui"

Swift - Get array item with an IndexSet

I have my Contact object: struct Contact: Codable, Identifiable { var id: Int = 0 var name: String var lastName: String var phoneNumber: String

How Can I Adjust TextField Placeholder Color : SwiftUI

I found that I can customize TextField style in swift like this.. struct BottomLineTextFieldStyle: TextFieldStyle { func _body(configuration: TextField<

Dynamically size a GeometryReader height based on its elements

I'm trying to do something that's pretty straight forward in my mind. I want a subview of a VStack to dynamically change its height based on its content (Probl

Error deleting records from a SwiftUI List and Realm

Has anyone been able to successfully integrate Realm with SwiftUI, especially deleting records/rows from a SwiftUI List? I have tried a few different methods bu

How can I initialize View Again in SwiftUI?

I’m using SwfitUI in my project and I have a NavigationView and List. I’m clicking cell after open the detail view and click navigation back button.

Drag and drop with custom type identifier doesn't work

I'm trying to achieve drag and drop on macOS with a custom type identifier to avoid collisions but it doesn't seem to work. First, here's a working example with

How can I reproduce Picker's selection binding?

I'm building a custom view and I'm trying to manipulate the active state of its children. I have this: struct Menu<Content>: View where Content: View {

Can’t pass data correctly to modal presentation using ForEach and CoreData in SwiftUI

Im trying to pass data of some object from list of objects to modal sheet, fetching data from CoreData. The problem is that no matter what object I click on i

SwiftUI stop Divider from expanding vertically in HStack

I'm using SwiftUI to create something like an alert popup, which I present from UIKit code using UIHostingController. The view looks like this: VStack(spacing:

SwiftUI Textfield state change stopped working with iOS 15.4.1

The following code has worked fine until iOS 15.4.1. It simply enables a button next to a textfield after the value entered is greater than 100000. It still w

how to do a simple scaling animation and why isn't this working?

i just read in stackoverflow i can only concatenate animation with delay, so i tried this here which simply shrinks and then scales the circle again. unfortunat

SwiftUI - Button with Image is clickable outside

I have a ScrollView with multiple Buttons. A Button contains a Image and a Text underneath. As the images are pretty large I am using .scaledToFill and .clipp

Custom Button in SwiftUI List

SwiftUI Custom Button in List I'm trying to create a custom button in a SwiftUI List. I want it to have a blue background with white text, and importantly, to

Remove default padding from List in SwiftUI

When using ScrollView the views inside it are spread across the whole screen width by default, but when using List, there is a padding on the sides. Is there a

SwiftUI using NSSharingServicePicker in MacOS

I am trying to use a Share function inside my MacOS app in SwiftUI. I am having a URL to a file, which I want to share. It can be images/ documents and much mor

Problem animating with animatableData in SwiftUI

SwiftUI not only gives us get automatic animation… it lets us control how the animation occurs, using the animatableData property. So cool! Only I

How to implement AdMob Open Ad in a SwiftUI project with SwiftUI App Cycle?

I'm trying to implement AdMob open ad in a SwiftUI project using Google's documentation: https://developers.google.com/admob/ios/app-open-ads. The problem is th

SwiftUI: Pop to root view when selected tab is tapped again

Starting point is a NavigationView within a TabView. I'm struggling with finding a SwiftUI solution to pop to the root view within the navigation stack when the

How do I split a TextField into characters?

enter image description hereSo basically, I want to put the word(s) inputted into a TextField into an array, but also split the word(s) up into separate charact

SwiftUI : How to set image in MacOs?

please help me to set image in macOs application using swiftUI Here is my Implementation: import SwiftUI struct SigninView: View { var body: some View {