Category "swiftui"

Change background color of TextEditor in SwiftUI

TextEditor seems to have a default white background. So the following is not working and it displayed as white instead of defined red: var body: some View {

UITabBar containing SwiftUI View

I have the below series of controllers and views. However, when I use the navigation link on the MoreView it changes the tabBarItem.title value. For instance it

SwiftUI set corner radius depending on its own height

When I set corner radius with constant value, depending on the size of the image, the results don't come out the way I want. Image(“myImage”) .c

SwiftUI app doesn't run when supporting iOS 13

App was working fine when the deployment target was 15.2, but then I needed to change the deployment target to iOS 13 to support more devices. Still works fine

Programmatically change to another tab in SwiftUI

I'm trying to implement in SwiftUI where you press a button in a view on one tab, it changes to another tab. I would do with UIKit: if [condition...button press

Focus TextField MacOS SwiftUI

I am trying to auto select a text field for a MacOS application. I added .focusable() but this does not change the result and the text field is still not auto s

SwiftUI: Make ScrollView scrollable only if it exceeds the height of the screen

Currently I have a view that looks like this. struct StatsView: View { var body: some View { ScrollView { Text("Test1") Tex

Automatically adjustable view height based on text height in SwiftUI

I am trying to create a view in SwiftUI where the background of the image on the left should scale vertically based on the height of the text on the right. I t

SwiftUI: How to force a specific view in an HStack to be in the centre

Given an HStack like the following: HStack{ Text("View1") Text("Centre") Text("View2") Text("View3")

Same ForEach loop twice in one SwiftUI View

When I use a ForEach loop over an array twice within a view, I get the following warning at runtime:LazyVGridLayout: the ID 84308994-9D16-48D2-975E-DC40C5F9EFFF

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