WorksheetsSwiftUI Test
Total questions: 20
Worksheet time: 10mins
What is SwiftUI primarily used for?
Developing console applications
Creating user interfaces for Apple platforms
Managing databases
Web development
Which syntax does SwiftUI use to simplify UI code?
Imperative Syntax
Declarative Syntax
Procedural Syntax
Object-Oriented Syntax
Which of the following is NOT a feature of SwiftUI?
Live Preview
Cross-platform Development
Built-in Accessibility
Integrated Database Management
How can SwiftUI views be customised for different device orientations?
Using CSS
Using VStack and HStack
Using SQL Queries
Using External Libraries
When would you use the @Binding property wrapper in SwiftUI?
To declare a state variable that only the current view needs to track.
To create a one-way data flow from a parent view to a child view.
To establish a two-way data connection between a parent and a child view.
To pass environment values down the view hierarchy.
In SwiftUI, how is a vertical stack of views created?
ZStack
HStack
VStack
StackView
What is the purpose of the @ObservedObject property wrapper?
To observe and respond to SQL database changes
To create observable objects that can be used for state management
To observe changes in a web service
To monitor and react to hardware sensor data
Which SwiftUI element is used to navigate between views?
NavigationLink
Button
Redirect
Hyperlink
How do you add a shadow to a text view in SwiftUI?
Using the .shadow() modifier
Applying a CSS class
Using the .border() modifier
Implementing a shadow protocol
What does the @EnvironmentObject property wrapper do?
Sets up a new environmental variable
Injects dependency objects into the view hierarchy
Changes the app's theme based on the user's system settings
Manages global settings for the SwiftUI application
Which SwiftUI structure is used to define a reusable component?
Func
Class
Struct
Enum
What is the primary use of a ViewBuilder in SwiftUI?
To create a reactive data flow between different parts of your UI.
To define a method that returns a custom view with a dynamic number of child views.
To simplify the management of state in complex view hierarchies.
To optimize the rendering performance of complex UI components.
How can you apply an implicit animation to a view in SwiftUI?
By wrapping the view update code inside a withAnimation block.
By directly modifying the view's properties without using an animation block.
By using .animation() modifier on a view.
By setting an @State variable with a custom animation object.
Which control would you use in SwiftUI to allow users to pick a value from a list of options?
Slider
TextField
Picker
Button
Which SwiftUI layout container allows for overlapping content?
ZStack
UIStackView
VStack
HSTack
Which SwiftUI concept is essential for sharing data across multiple views without passing it explicitly?
EnvironmentObject
Data Passing
DataStream
@SharedData property wrapper
How do you localise text in a SwiftUI app for multiple languages?
Using the @Localise property wrapper
Implementing a translation API
Direct translation within the code
Using the Localisable.strings file
What SwiftUI view is used to create a scrollable list of items?
UITableView
VStack
ScrollView
ListView
In SwiftUI, what does the @State property wrapper do?
It manages complex object states across multiple views.
It declares a source of truth for a value within a view that triggers UI updates when the value changes.
It binds data between a parent and a child view.
It observes an object’s properties for changes and updates the UI accordingly.
How would you push some content, e.g a VStack to the top of a view if it is not where you want it?
alignment: .top
alignment: .leading
alignment: .trailing
Spacer()
