App-Development-with-Swift-Certified-User試験無料問題集「Apple App Development with Swift Certified User 認定」

Given the function, which two function calls are valid? (Choose 2.)

解説: (GoShiken メンバーにのみ表示されます)
Review the code.
struct ContentView: View {
let fruits = [ " Apple " , " Banana " , " Kiwi " ]
var body: some View {
List(fruits, id: \.self) { fruit in
Text(fruit)
.font(.headline)
.padding()
}
}
}
Which of the following statements is true about the code?

解説: (GoShiken メンバーにのみ表示されます)

Which two assignments of a value to direction are allowed? (Choose 2.)

解説: (GoShiken メンバーにのみ表示されます)
When you press ' Show Button ' on your app. a modal View appears.
Complete the code by selecting the correct option from each drop-down list.
Note: You will receive partial credit for each correct answer.
正解:

Explanation:

This question belongs to View Building with SwiftUI , specifically the domain on creating a multi-view app with navigation stacks, links, and sheets .
To present a modal view in SwiftUI when a Boolean state changes, the correct modifier is .sheet . The matching sheet API for a Boolean binding is:
sheet(isPresented: $showInfo) {
// modal content
}
So the first blank must be .sheet , and the second blank must be (isPresented: .
The logic works like this:
* @State stores the local Boolean that controls presentation.
* Pressing the button calls showInfo.toggle(), changing the value from false to true.
* When that Boolean becomes true, the .sheet(isPresented:) modifier presents the modal view.
* When the modal is dismissed, SwiftUI updates the Boolean back as needed.
There is also a typing issue in the screenshot: the state variable appears as ShowInfo, while the button and binding use showInfo. Swift is case-sensitive, so those names must match. The corrected code should use the same identifier consistently, such as:
@State var showInfo = false
Therefore, the correct dropdown selections are:
sheet
(isPresented:
You have a set of Views within a ZStack that produce the screen below:

Arrange the lines of code that will make up the ZSlack so that the View appears as shown.
正解:

Explanation:

This question belongs to View Building with SwiftUI , specifically stacking views and applying modifiers. A ZStack layers views from back to front, so the first item becomes the background and later items appear on top. To match the screenshot, the black background must be the back layer, so Color.black goes first. The large white circle sits above that, so Circle() followed by .foregroundStyle(.white) comes next. Finally, the red heart image sits on top of the circle, so Image(systemName: " heart " ).resizable() followed by .
foregroundStyle(.red).frame(width: 200, height: 200) must be last. SwiftUI's Image.resizable() allows the symbol image to scale to the frame you apply, and foregroundStyle sets the visible color styling for the shape and symbol.
So the intended structure is:
ZStack {
Color.black
Circle()
.foregroundStyle(.white)
Image(systemName: " heart " ).resizable()
.foregroundStyle(.red)
.frame(width: 200, height: 200)
}
This produces a black background, a white circular shape, and a centered red heart on top, exactly as shown.