Post

Replies

Boosts

Views

Activity

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.2k
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
2
0
665
Feb ’22
Preparation for Swift Student Challenge
Helle everyone! I was preparing for this year's Swift Student Challenge, and I have some questions about it. I know that Apple every year changes something in the Challenge, but I want to be ready. As I know for participating to the challenge I have to build a playground in Swift Playgrounds. So for that in Swift Playgrounds I have to use SwiftUI kit or build it in another way? PS: if someone knows some Swift Playgrounds tutorials please suggest me here. Thank you very much!
3
0
1k
Feb ’22
iOS 15.2.1
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.
3
0
1.3k
Jan ’22
Scroll automatically
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())
0
0
755
Jan ’22
Scroll according to mouse position
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())
0
0
394
Jan ’22
Scroll according to mouse position
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())
0
0
373
Jan ’22
Where to put the animation
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())
2
0
599
Jan ’22
Keep face up the cards if equal
Hi guys, I need a little help with my code, I was creating this playground and I want that the cards will stay face up if they are equal... I can't find tutorial and I tried different lines of code but it doesn't work. So please can anyone help me there? I'll thank you very much. struct ContentView: View {     @State var flipped1 = false      @State var flipped2 = false      var body: some View {               LazyVGrid(columns: columns) {             Group {                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(flipped1 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😀").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped1 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped1 ? 1 : 0))                     .rotation3DEffect(flipped1 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default, value: flipped1)                     .onTapGesture {                         flipped1.toggle()                     }                                  RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(flipped2 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😀").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped2 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped2 ? 1 : 0))                     .rotation3DEffect(flipped2 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         flipped2.toggle()                     }
4
0
704
Jan ’22
Need a help with my app
Hi guys I'm trying to build a game (cards game precisely) and I need that when the user finds the same cards the game has to stop... I watched different videos on internet and tried a lot of lines of code but I can't do this. So please, can anyone help me? Thank you. I leave you my code: import SwiftUI import PlaygroundSupport let columns = [GridItem(.flexible()),                GridItem(.flexible()),                GridItem(.flexible()),                GridItem(.flexible())] struct ContentView: View {     @State var flipped1 = false      @State var flipped2 = false      @State var flipped3 = false      @State var flipped5 = false      @State var flipped6 = false      @State var flipped7 = false      @State var flipped8 = false      @State var flipped9 = false           var body: some View {         LazyVGrid(columns: columns) {             Group {                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(flipped1 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😀").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped1 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped1 ? 1 : 0))                     .rotation3DEffect(flipped1 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default, value: flipped1)                     .onTapGesture {                         flipped1.toggle()                     }                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(flipped2 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😜").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped2 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped2 ? 1 : 0))                     .rotation3DEffect(flipped2 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         flipped2.toggle()                     }                                  RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(self.flipped3 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😘").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped3 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped3 ? 1 : 0))                     .rotation3DEffect(self.flipped3 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         self.flipped3.toggle()                     }                                  RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(self.flipped5 ?  Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("🥶").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped5 ? 180 : 0), axis: (x: CGFloat(0), y:CGFloat(10), z: CGFloat(0))).opacity(flipped5 ? 1 : 0))                     .rotation3DEffect(self.flipped5 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         self.flipped5.toggle()                     }                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(self.flipped6 ? Color(.systemIndigo) : .purple)                     .padding()                     .overlay(Text("😡").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped6 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped6 ? 1 : 0))                     .rotation3DEffect(self.flipped6 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         self.flipped6.toggle()                     }                                  Group {                     RoundedRectangle(cornerRadius: 20)                         .frame(width: 140, height: 170)                         .foregroundColor(self.flipped7 ? Color(.systemIndigo) : .purple)                         .padding()                         .overlay(Text("🥶").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped7 ? 180 : 0), axis: (x: CGFloat(0), y:CGFloat(10), z: CGFloat(0))).opacity(flipped7 ? 1 : 0))                         .rotation3DEffect(self.flipped7 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                         .animation(.default)                          .onTapGesture {                             self.flipped7.toggle()                         }                     RoundedRectangle(cornerRadius: 20)                         .frame(width: 140, height: 170)                         .foregroundColor(self.flipped8 ? Color(.systemIndigo) : .purple)                         .padding()                         .overlay(Text("😘").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped8 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped8 ? 1 : 0))                         .rotation3DEffect(self.flipped8 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                         .animation(.default)                          .onTapGesture {                             self.flipped8.toggle()                         }                     RoundedRectangle(cornerRadius: 20)                         .frame(width: 140, height: 170)                         .foregroundColor(self.flipped9 ? Color(.systemIndigo) : .purple)                         .padding()                         .overlay(Text("😡").font(.system(size: 80)).rotation3DEffect(Angle(degrees: flipped9 ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped9 ? 1 : 0))                         .rotation3DEffect(self.flipped9 ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                         .animation(.default)                          .onTapGesture {                             self.flipped9.toggle()                         }                                      }             }         }     } } PlaygroundPage.current.setLiveView(ContentView())
2
0
578
Jan ’22