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.
Questions tagged [swiftui-view]
64 questions
0
votes
1 answer
Go to a new view when button tapped (SwiftUI)
My expectation: I want to open a new full screen view (PhoneNumberView) on click of confirmation dialog button.
Reality: Nothing happens when I click to Back button (please check my code below)
Here is my code:
…

Darya
- 11
- 2
0
votes
1 answer
How to align SwiftUI view height to its overlay view height
I have this corresponding structure of a view:
ZStack {
Color.gray.edgesIgnoringSafeArea(.all)
CostumShape()
.fill(Color.white)
.cornerRadius(10, corners: .allCorners)
…

Adrian Macarenco
- 165
- 2
- 11
0
votes
0 answers
How can I make progress view that can apply on every view?
Can I make progress view that can apply on every view due to condition in SWIFTUI, like some extension that put progress view over current view?
I have tried with view modifier like I handle API errors and alerts:
class ProgressViewHandling:…

NikolaSwift
- 35
- 4
0
votes
1 answer
How to overlay view on top of multiple other views in a VStack in SwiftUI
In SwiftUI I currently have a VStack of views, and I'd like to put an overlay over the bottom two views, like this:
VStack {
Spacer()
Group {
centerView
Spacer()
}
.overlay(overlayedView)
}
The goal of the above layout is ensure…

wristbands
- 1,021
- 11
- 22
0
votes
1 answer
How do I show another SwiftUI View with code?
Im trying to show another view with SwiftUI, when a button is pressed. Here is what I am trying:
import SwiftUI
struct Home: View {
var body: some View {
VStack {
Text(/*@START_MENU_TOKEN@*/"Hello,…

WilliApple
- 21
0
votes
2 answers
Custom SwiftUI view does not update when state changes
I have modified a custom 5 star rating view (https://swiftuirecipes.com/blog/star-rating-view-in-swiftui) to suite my needs. I use that view in several places in my app to display the current rating for a struct and to change the rating through a…

Ferdinand Rios
- 972
- 6
- 18
0
votes
1 answer
How to set up Textfield and Button in Custom SwiftUI View
I am attempting the configure the text field and button in my openweathermap app to be in its own view other than the main content view. In TextFieldView, the action of the button is set up to call an API response. Then, the weather data from the…

JS_is_awesome18
- 1,587
- 7
- 23
- 67
0
votes
1 answer
How do I have private state variables for a childview in swiftui?
So I am creating this app where a user chooses the multiplication table he wishes to practice on, and the number of questions on the first view, then, by pressing a button,
it goes on to the next view which passes this data, which will then create a…

Charlie Tan
- 3
- 4
0
votes
1 answer
Return Text from another view Error, missing argument parameter
struct SettingsView: View {
var body: some View {
welcomeView()
//:Missing argument for parameter 'currentAuthStat' in call
}
}
struct welcomeView: View {
@Binding var currentAuthStat:…

officer_Krupke
- 27
- 4
0
votes
0 answers
How to prevent view from being pushed by other view expanding in SwiftUI
If you have something like this. You'll see that the bottom views rectangle 1 and rectangle 2 are aligned with one another.
HStack(spacing: 0) {
Rectangle()
.fill(Color.smashFrameStartup)
…

Petesta
- 1,623
- 3
- 19
- 29
0
votes
1 answer
Incrementing the variable in a function is creating error while preview (swiftui)
I have this code inside which I'm calling "makeView" function that returns a View, and in the makeView function I'm incrementing the variable "id" and passing it to the View, but when I do this it shows this error
"Updating a preview from…

sharpnife
- 198
- 12
0
votes
1 answer
SwiftUI View Extension is called on View load/refresh
We created a custom view extension to extend the functionality of .alert and add a bunch of customizations to fit with our needs;
import SwiftUI
extension View {
public func alertX(isPresented: Binding, content: () -> AlertX) -> some…

ColinMasters
- 511
- 7
- 19
0
votes
0 answers
SwiftUI - How to create a transition animation between views without impacting child view?
In SwiftUI, I've got an overarching view setup like this:
import SwiftUI
struct ContentView: View {
@State var index: Int = 0
var body: some View {
if self.index == 0{
FirstView(index: $index)
}
if…

Evan
- 1,892
- 2
- 19
- 40
0
votes
1 answer
Swift - function to return different value based on another variable
I have a view (view1) to display different data, and I would like that view to change based on another variable.
struct View1: View {
let array = myFunc()
var body: some View {
VStack {
Text("\(settings.score)")
…

Carl Bryers
- 53
- 7
0
votes
1 answer
macOS - Error while passing information through UI View
I am trying to pass information from one SwiftUI View (let's say View1) to another one (View2) using NavigationLink. I have found this article, but when I try to run it I get the error "Cannot find type 'Event' in scope":
Here is my code for…

stefthedoggo4
- 49
- 6