Category "swiftui"

How do I include iOS App Icon image within the app itself?

I have standard iOS app, with a standard app icon contained in Assets. I'd like to display the app icon within the app (using SwiftUI). Note that I am not ask

SwiftUI Mask a rectangle inside a rounded rectangle

Hello there. I am wondering, in SwiftUI, how do you mask the contents of a rounded rectangle so that a child rectangle clips the corners. In my example I ha

SwiftUI System Cursor

I'm trying to change the cursor to a crosshair in SwiftUI on MacOS. I've put the following code into the AppDelegate applicationDidFinishLaunching() function:

SwiftUI: Why does @AppStorage work differently to my custom binding?

I have a modal presented Sheet which should display based on a UserDefault bool. I wrote a UI-Test which dismisses the sheet and I use launch arguments to contr

How to make List Item row with a button inside not clickable in Swift UI?

Is there a way to make it so that the whole row of a list is not clickable? I'm trying to make it so that only the button is clickable on the button row. As

Making parts of text bold in SwiftUI

I was wondering how I would make only sections of a text bold while keep the rest 'regular' in SwiftUI. I currently have: Text("Coronavirus Disease of 2019")

Is there a better way to implement a shake animation in swiftui?

I'm trying to get a button to shake when the user tries to log in without filling all the textfields in, and this is what I've come across so far: struct Shake

Images inaccessible from asset catalog in a SwiftUI framework

I've created an iOS framework that contains a single SwiftUI View. I've then added an Asset Catalog with a single image. Trying to access that image from the Sw

SwiftUI ZStack: Align some descendants to bottom, and some to top

As a root view of my app, I have a ZStack, and I would like to add two floating bars, one to the bottom, and one to the top of the viewport. With a single bar i

How to create a see-through Rectangle in SwiftUI

I want to make an Image 100% transparent through a small rectangle and 50% transparent from all others. As if making a small hole to see-through the small recta

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