Questions tagged [swiftui-view]

For questions about View - a component in Apple's SwiftUI framework that represents part of your app’s user interface and provides modifiers that you use to configure views.. When using this tag also include the more generic [swiftui] tag where possible.

64 questions
1
vote
1 answer

Make second view gray SwiftUI

I have 2 views. 1 main view and 1 alert view. The alert view will appear in the front of the main view. I want to lower the white color from the entire main view when this happens. Like a gray or light gray when the alert view is on front. My main…
1
vote
1 answer

Aligning toggles in a SwiftUI View

I have this code that contains the labels and toggles shown in the screenshot below VStack(alignment: .leading) { HStack() { Text("Autostart:") .font(.custom("SFProText-Medium", size: 12)) …
narner
  • 2,908
  • 3
  • 26
  • 63
1
vote
2 answers

I am unable to use a spacer to push a text view to the top of my swift ui VStack view, when adding UI wrappers

I have got a piece of code below but the issue is the text field is positioned in the middle of the view and when I add spacers below to push the textfield to the top of the view, it doesn't get pushed the textfield to the top of the view but rather…
Emere
  • 45
  • 4
1
vote
0 answers

Load Various Custom Views inside 'some View '

I've been working on a SwiftUI project that generates UIs based on Server responses using JSON In order to do that I have created a FormBuilder Now I want to show various types of custom fields like TextField, DateField, TextArea all fields…
1
vote
1 answer

How do I prevent SwiftUI View from taking up any space?

I’m pretty new to SwiftUI and am working on this little project. I want to place an image either on top of or between lines, depending on the position variable. struct ContentView: View { @State var position = 5 var body: some View { …
Arrenz
  • 33
  • 8
1
vote
1 answer

SwiftUI function shows "Modifying state during view update, this will cause undefined behavior."

The code works in that it brings up 5 random consonants and 2 vowels just like I want, but it is showing a warning message that "Modifying state during view update, this will cause undefined behavior." I am fairly new to Swift and I don't understand…
1
vote
2 answers

Pass generic view into SwiftUI View

I am trying to build out a custom scroll view that can take in different cells I have created and present those in the scroll view. I cannot figure out how to pass a generic SwiftUI view into the constructor of my custom scroll view struct, is it…
tHatpart
  • 1,302
  • 3
  • 12
  • 27
1
vote
2 answers

How to Align an image to the center of a screen using SwiftUI?

I'm trying to align an image to the center of the screen in Swift/SwiftUI. GeometryReader { geometry in HStack { Spacer() Color.white .ignoresSafeArea() Image("1Pzpe") …
nai hamdan
  • 13
  • 1
  • 5
1
vote
1 answer

SwiftUI - view expand from the bottom of frame

I'd like to display a number of values as a continuous value from 0 to 1. I'd like them to grow from the bottom up, from 0 displaying no value, to 1 displaying a full height. However, I'm unable to make it "grow from the bottom". I'm not sure what a…
Hoopes
  • 3,943
  • 4
  • 44
  • 60
1
vote
1 answer

SwiftUI: Frame modifier in ZStack affecting other views

struct CircleTestView: View { let diameter: CGFloat = 433 var body: some View { ZStack { Color(.yellow) .ignoresSafeArea() VStack { Circle() …
Grambo
  • 887
  • 8
  • 25
1
vote
2 answers

Override the functionality of the button from another View?

I got a re-usable searchbar in a separate view that looks like this: struct SearchBar: View { @Binding var searchText: String @Binding var isSearching: Bool var body: some View { HStack { HStack { …
erikvm
  • 858
  • 10
  • 30
1
vote
1 answer

SwiftUI: clipping an image to shape

I'm currently working on some loading screen in SwiftUI and want to implement some kind of image animation with a simple path. I've done a simple Shape-animation with the path, but Ive stuck with clipping an image to it. Is it possible? I just want…
Nokt
  • 29
  • 5
1
vote
1 answer

How to wrap #available in this custom .if extension on a SwiftUI View?

I'm using this .if extension which works great and should be added to SwiftUI, however it won't work in this case to check #available because #available may only be used as condition of an 'if', 'guard' or 'while' statement How can I make it work…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
1
vote
3 answers

Passing calculated variable to another View

I am trying to create my own grid, which resizing to every element. It's okay with that. Here is a code GeometryReader { geo in let columnCount = Int((geo.size.width / 250).rounded(.down)) let tr =…
Higherous
  • 92
  • 1
  • 6
1
vote
2 answers

Custom shape registers taps outside drawn path

I created a custom Arc shape in SwiftUI, but when I add an onTapGesture modifier to it, it registers taps outside the area I drew for the Arc (it registers taps anywhere within the rect used to draw the Arc). How can I make sure the taps only…
wristbands
  • 1,021
  • 11
  • 22