Hello everyone,
I was trying to create something in Swift Playgrounds when this error appears, can someone tell me what it means and how can I fix it?
Thanks
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hey there,
I would like to create a card game (I'm following the Stanford University's tutorial) and I want to Scroll the view according to the position of the mouse, like if it's to the top so I would like that it automatically rolls up, so if it's to the down, scroll automatically to the down:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View{
HStack {
CardView()
CardView()
CardView()
CardView()
}
.padding()
.foregroundColor(Color(.systemRed))
}
}
struct CardView: View {
@State var isFaceUp = false
var body: some View {
ZStack {
let shape = RoundedRectangle(cornerRadius: 20)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.stroke(lineWidth: 3)
Text("😀").font(.system(size: 80))
} else {
shape.fill()
}
}
.onTapGesture(perform: {
isFaceUp = !isFaceUp
})
}
}
PlaygroundPage.current.setLiveView(ContentView())
Hey there, I would like to create a card game (I'm following the Stanford University's tutorial) and I want to Scroll the view according to the position of the mouse, like if it's to the top so I would like that it automatically rolls up, so if it's to the down, scroll automatically to the down:
This is my code:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View{
HStack {
CardView()
CardView()
CardView()
CardView()
}
.padding()
.foregroundColor(Color(.systemRed))
}
}
struct CardView: View {
@State var isFaceUp = false
var body: some View {
ZStack {
let shape = RoundedRectangle(cornerRadius: 20)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.stroke(lineWidth: 3)
Text("😀").font(.system(size: 80))
} else {
shape.fill()
}
}
.onTapGesture(perform: {
isFaceUp = !isFaceUp
})
}
}
PlaygroundPage.current.setLiveView(ContentView())
Hi there!
I'm trying to create an app which scrolls automatically when my mouse goes to the top of the screen or to the bottom. For example the mouse goes towards the top, it has to scroll to the top and vice versa. So if it possible help me please.
Thanks very much!
I leave you my code:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View{
HStack {
CardView()
CardView()
CardView()
CardView()
}
.padding()
.foregroundColor(Color(.systemRed))
}
}
struct CardView: View {
@State var isFaceUp = false
var body: some View {
ZStack {
let shape = RoundedRectangle(cornerRadius: 20)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.stroke(lineWidth: 3)
Text("😀").font(.system(size: 80))
} else {
shape.fill()
}
}
.onTapGesture(perform: {
isFaceUp = !isFaceUp
})
}
}
PlaygroundPage.current.setLiveView(ContentView())
Hello everyone!
I have updated my iPhone to iOS 15.2.1 and before this update my phone after the good the sleep mode turns off, it appears a screen with written on it “Good Morning” and the weather. But since I have updated my device to iOS 15.2.1 it isn’t showing me this screen. Is it a feature that Apple has deleted or is this a bug?
Thank you.
Hello there!
I would like to build a playground using Swift Playgrounds in AR. And I want to ask if it is possible to do it on the Mac or I can only do it with the iPad?
Thank you.
Hello,
I've seen that Apple has posted a news for some online sessions starting from February 15 to March 29. And I'd like to participate there but for now I haven't posted any app on the App Store. So I would like to ask that I can still participate also if I'm in the beginning?
These are the sessions: https://developer.apple.com/events/view/upcoming-events
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store
App Store Connect
Mac App Store
Hello there! I would like to move the object according to the button press. In this code, I have the circle and I like to move it down if I press the down button. Can anyone tell me how can I do this?
Thanks.
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
Circle()
.frame(width: 80, height: 80)
Spacer(minLength: 20)
Button{
} label: {
Image(systemName: "arrowtriangle.down.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
Hi there!
Does anyone know software (possibly online) for creating 3D assets for inserting them into my project/playground?
Thanks
Hello,
Is it possible to build something in 3D in Swift Playgrounds? If yes how can I do it. Please help me.
Thanks!
Hello there! Can someone tell me the syntax to rotate an image in SwiftUI (not rotating it in the effect, but add the orientation).
Thanks very much.
Hello everyone,
Can someone tell me how to move the circle in the same position of the arrow (like to go up if I press up, down if I press down... and so right if I press right) but it doesn't go right, I can't know why. Please can someone help me to figure out this?
Here's the code:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var offset: CGFloat = 0
var body: some View {
Circle()
.frame(width: 80, height: 80)
.position(x: 140, y: 140 + offset)
Spacer(minLength: 20)
Button(
action: {
offset += 20
}, label: {
Image(systemName: "arrowtriangle.down.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
Button(
action: {
offset += 20
}, label: {
Image(systemName: "arrowtriangle.right.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
}
}
PlaygroundPage.current.setLiveView(ContentView())
Thanks in advance.
Hi there!
I want to change the current circle to a rectangle when I press the Right button. Is it possible if yes how can I it?
Code:
struct ContentView: View {
@State var vOffset: CGFloat = 0
@State var hOffset: CGFloat = 0
var body: some View {
Circle()
.frame(width: 80, height: 80)
.position(x: 140 + hOffset, y: 140 + vOffset)
Spacer(minLength: 20)
Button(
action: {
vOffset += 20
}, label: {
Image(systemName: "arrowtriangle.down.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
Button(
action: {
hOffset += 20
}, label: {
Image(systemName: "arrowtriangle.right.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
}
}
Thanks.
Hi there!
I want to change the current circle to a rectangle when I press the Right button. Is it possible if yes how can I it?
Here's the code:
struct ContentView: View {
@State var vOffset: CGFloat = 0
@State var hOffset: CGFloat = 0
var body: some View {
Circle()
.frame(width: 80, height: 80)
.position(x: 140 + hOffset, y: 140 + vOffset)
Spacer(minLength: 20)
Button(
action: {
vOffset += 20
}, label: {
Image(systemName: "arrowtriangle.down.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
Button(
action: {
hOffset += 20
}, label: {
Image(systemName: "arrowtriangle.right.circle.fill")
.resizable()
.foregroundColor(.blue)
.frame(width: 70, height: 70)
.padding()
}
)
}
}
Hello world,
I'm building a cards came using SwiftUI and for now I have created the cards, but I want to shuffle them, so mix them randomly. Can anyone please tell me the syntax to do it? Thanks very much.