Post

Replies

Boosts

Views

Activity

App Store Sessions
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
2
0
694
Feb ’22
Move according to the button
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())
1
0
1.3k
Feb ’22
Move the circle according the arrow
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.
0
0
642
Feb ’22
Change image with click
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.
0
0
494
Feb ’22
Change image with click
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() } ) } }
2
0
1.3k
Feb ’22
Show a badge on a Rectangle
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.
2
0
2.2k
Mar ’22
What's wrong here?
Hello everyone, I'm trying to make particle effect in SwiftUI, following a YouTube tutorial and this is what I made, despite I wrote the same code as the video, it gives me this error (which doesn't appear in the video). So can anyone tell me what I did wrong? Here's my code: And the link for the tutorial: https://www.youtube.com/watch?v=oj4HEqkDvBY import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {         Text("Hello, world!")     } } struct ParticleEffect: ViewModifier {     let count: Int     let duration: Double = 2.0     @State var time: Double = 0.0     func body(content: Content) -> some View {         let animation = Animation.linear(duration: duration)             .repeatForever(autoreverses: false)         return  ZStack {             ForEach(0..<count) { index in                 content                     .scaleEffect(CGFloat((duration-self.time)/duration))                     .modifier(ParticleMotion(time: self.time)) // ERROR: Cannot find 'ParticleMotion' in scope                     .opacity((duration-self.time)/duration)                     .animation(animation.delay(Double.random(in: 0..<self.duration)))                     .blendMode(.plusLighter)             }             .onAppear {                 withAnimation() {                     self.time = duration                 }             }         }     } } PlaygroundPage.current.setLiveView(ContentView())
1
0
501
Mar ’22
Swift Playgrounds ARKit on Mac
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.
Replies
1
Boosts
0
Views
1k
Activity
Feb ’22
App Store Sessions
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
Replies
2
Boosts
0
Views
694
Activity
Feb ’22
Move according to the button
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())
Replies
1
Boosts
0
Views
1.3k
Activity
Feb ’22
Online software for creating 3D assets
Hi there! Does anyone know software (possibly online) for creating 3D assets for inserting them into my project/playground? Thanks
Replies
0
Boosts
0
Views
562
Activity
Feb ’22
Build in 3D in Swift Playgrounds
Hello, Is it possible to build something in 3D in Swift Playgrounds? If yes how can I do it. Please help me. Thanks!
Replies
2
Boosts
0
Views
992
Activity
Feb ’22
Rotate an image
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.
Replies
0
Boosts
0
Views
519
Activity
Feb ’22
Move the circle according the arrow
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.
Replies
0
Boosts
0
Views
642
Activity
Feb ’22
Change image with click
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.
Replies
0
Boosts
0
Views
494
Activity
Feb ’22
Change image with click
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() } ) } }
Replies
2
Boosts
0
Views
1.3k
Activity
Feb ’22
Shuffle randomly in SwiftUI
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.
Replies
2
Boosts
0
Views
1.3k
Activity
Feb ’22
Add badge to an object
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.
Replies
2
Boosts
0
Views
716
Activity
Feb ’22
Show a badge on a Rectangle
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.
Replies
2
Boosts
0
Views
2.2k
Activity
Mar ’22
Move with pointer
Hello there! I would like to build a game in SwiftUI where you can move an object with your mouse (for example: a rectangle points your mouse, and it goes where your mouse goes). How can I do it?
Replies
1
Boosts
0
Views
696
Activity
Mar ’22
What's wrong here?
Hello everyone, I'm trying to make particle effect in SwiftUI, following a YouTube tutorial and this is what I made, despite I wrote the same code as the video, it gives me this error (which doesn't appear in the video). So can anyone tell me what I did wrong? Here's my code: And the link for the tutorial: https://www.youtube.com/watch?v=oj4HEqkDvBY import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {         Text("Hello, world!")     } } struct ParticleEffect: ViewModifier {     let count: Int     let duration: Double = 2.0     @State var time: Double = 0.0     func body(content: Content) -> some View {         let animation = Animation.linear(duration: duration)             .repeatForever(autoreverses: false)         return  ZStack {             ForEach(0..<count) { index in                 content                     .scaleEffect(CGFloat((duration-self.time)/duration))                     .modifier(ParticleMotion(time: self.time)) // ERROR: Cannot find 'ParticleMotion' in scope                     .opacity((duration-self.time)/duration)                     .animation(animation.delay(Double.random(in: 0..<self.duration)))                     .blendMode(.plusLighter)             }             .onAppear {                 withAnimation() {                     self.time = duration                 }             }         }     } } PlaygroundPage.current.setLiveView(ContentView())
Replies
1
Boosts
0
Views
501
Activity
Mar ’22
Display multiple overlays
Hello guys, Is it possible to display different overlays on a text in SwiftUI? If someone knows how to do it, please help me with an example. I am in trouble with it. Thank you very much!
Replies
0
Boosts
0
Views
681
Activity
Mar ’22