Hello there,
What is the difference between @ObservedObject, ObservableObject and @StateObject in SwiftUI?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
Hello! I was trying to create a cards game following the Stanford University CS193p tutorial and I had a problem, in the tutorial they didn't add any animation and I would like to add one but I can't understand where exactly I have to write the command. Can someone help me?
Thank you very much!
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,
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,
Is it possible to build something in 3D in Swift Playgrounds? If yes how can I do it. Please help me.
Thanks!
Hi everyone,
I want to use SceneKit in Swift Playgrounds, or import the Xcode project with SceneKit into Swift Playgrounds. Is it possible?
Hello everyone,
I decide to send a feedback in the Feedback app about the software beta version. But I have a question about it, when I post my feedback only Apple team can see it or it's visible to anyone?
Thanks in advance.
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?
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.
Hello guys, I want to show a badge on an object in SwiftUI (I want the rectangle to show the badge on it every time I press it). I did some tests, but it isn't working. Can someone help me to build this?
Thanks a lot.
Hello guys, I want to show a badge on an object in SwiftUI, precisely I want the rectangle to show the badge on it every time I press it. I did some tests, but it isn't working. Can someone help me to build this?
Here’s my code:
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
Button(action: {
badge(9)
}, label: {
Rectangle()
.frame(width: 180, height: 200)
.foregroundColor(.blue)
})
}
}
PlaygroundPage.current.setLiveView(ContentView())
Thanks a lot.
Hi everyone,
I want to try my Xcode project on my iPhone, but I can't because of an error, which says "Unable to prepare iPhone for development". Can someone help me to try my app on my iPhone and fix this error?
Thank you!
Hello there! I'm trying to create something in SwiftUI, but there's a problem: I can't have 2 cards with the same content, does anyone know a way to have the same emojis in 2 separate cards?
Here's my code:
import PlaygroundSupport
import SwiftUI
struct ContentView: View {
var emojis: [String] = ["🐶", "🐱", "🐱", "🦊", "🦁", "🐝", "🐼", "🐷", "🐮"]
var body: some View {
LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {
ForEach(emojis, id: \.self, content: { emoji in
emojiView(content: emoji)
})
}
}
struct emojiView: View {
var content: String = ""
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 20)
.frame(width: 90, height: 120)
.foregroundColor(.yellow)
Text(content).font(.largeTitle)
}
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
Hello everyone! Can I attach an object with a magnete animation to the other in SwiftUI?
Please show me that with a simple example.
Thank you in advance.