Post

Replies

Boosts

Views

Activity

Overlapping objects
Hello everyone! I'm having a problem with my code and I don't know how to fix it. In fact, when I click the green circle, it gets bigger by wiping out the others, but the purple overlaps. Is there a way to get the purple away too? Another problem: I have a warning where it says  .animation(.spring()) and the warning says "'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead." import SwiftUI struct ContentView: View {         var body: some View {             LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                 createCircle()                     .foregroundColor(.blue)                 createCircle()                     .foregroundColor(.green)                 createCircle()                     .foregroundColor(.purple)                 createCircle()                     .foregroundColor(.orange)                 createCircle()                     .foregroundColor(.yellow)         } } struct createCircle: View {     @State var scale : CGFloat = 0.25     var body: some View {         ZStack {             Circle()                  .frame(width: 500 * scale, height: 500 * scale)                  .onTapGesture {                      scale = 5                  }                  .animation(.spring()) // WARNING: 'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead.                  .animation(.interpolatingSpring(stiffness: 50, damping: 1), value: scale)         }     } } } Can anyone help me?
1
0
1.1k
Apr ’22
Error in my code
Hi everyone! I was working on a playground in Swift Playground and I got an error. I can't understand what this error means, can anyone help me? This is my code: struct Preview: View {     @State var isPlaying = true     @State var num1 = 60     @State var num2 = 150     var body: some View {         if isPlaying == true { // ERROR: Only concrete types such as structs, enums and classes can conform to protocols // Required by static method 'buildBlock' where 'C0' = ()             num1 += 1             print("\(num1)")         }     } } Thanks.
1
0
662
Apr ’22
App crashed
Hello there! I was trying to build an app with the new App feature in Swift Playgrounds for Mac. But I have an error message in my code, and I can't understand how to fix it. Can anyone help me to solve this error. Here's the code: import SwiftUI struct Something: View {     let rows = 17     let columns = 17     let size: CGFloat = 10     let blocks: [[Color]] = [[.purple, .purple]]     var body: some View {         VStack {             ForEach((0...self.rows - 1), id: \.self) { row in                  HStack (spacing: 0) {                     ForEach((0...self.columns - 1), id: \.self) { col in                         VStack (spacing: 0) {                             Rectangle()                                 .frame(width: self.size, height: self.size)                                 .foregroundColor(self.blocks[row][col]) // index out of range: the requested index was outside the bounds of the array.                         }                     }                 }             }         }     } }
1
0
822
Jun ’22
App suggestion
Hi developers! Does anyone know an app to make a short animated film like this https://youtu.be/a4PraWW82_A, which is also free? I used Procreate before, but there is the layer limit and since my video is a little long I need more layouts :( thanks in advance
Topic: Design SubTopic: General Tags:
1
0
894
Aug ’22
Build a website from scratch
Hello developers! I have a question about which programming language is good for building a website. I searched on the internet and it says that CSS and HTML are the most used, so suppose I want to use CSS, now the question is: where can I code to build the website? For example if I want to code in SwiftUI there are some apps (Xcode and Swift Playgrounds) to do it, but how can I do with the website in CSS? If someone has the right answer, please help me. Thanks.
Topic: Safari & Web SubTopic: General Tags:
1
0
1.2k
Aug ’22
Falling effect SwiftUI
Hi everyone! import SwiftUI struct ContentView: View { let screenHeight = UIScreen.main.bounds.height let letters: [String] = ["A", "B"] @State private var yOffset: CGFloat = 0.0 var body: some View { ForEach(letters, id: \.self) { letter in Text(letter) .padding() .font(.largeTitle) .offset(x: 0, y: yOffset) .animation(Animation.linear(duration: 5.0).repeatForever(autoreverses: false)) .onAppear { yOffset = screenHeight - 90 } } } } I would like in this code, the letters to fall from the beginning of the screen to its end, I have the size of screen's height, but actually I can't understand how I can I use it, until the letters can start from the beginning of the screen. And I would also like that once they reach the bottom, they start falling again... I can't understand how this effect can be achieved, is there anyone who can help me?
1
0
588
Feb ’24
Button animation bug: repeated movement behaviour
Hi, I've created an effect that after clicking on the "Hello, world!" button, it has to move (first move is when the user taps on it), and then it has to move again, but this time without any interaction, and it does. But the problem is that when I click again on it, it goes back and then returns to the same position, I can't understand how to solve this issue. This is my code: import SwiftUI public struct ContentView: View { @State var xPos: CGFloat = 300 @State var yPos: CGFloat = 400 @State var size: CGFloat = 120 public var body: some View { ZStack { Image("background") .resizable() .frame(width: 700, height: 500) .padding() .overlay { Button(action: { xPos = 170 yPos = 310 size = 60 DispatchQueue.main.asyncAfter(deadline: .now() + 1) { xPos = 700 } }) { Text("Hello, world!") .font(.system(size: size)) .position(x: xPos, y: yPos) } .animation(.spring) } } } } Can anyone help me? Thanks in advance!
1
0
538
Feb ’24
Apple Developer Membership is activated
Hi, I heard that Apple will send me an email saying that my Apple developer membership is activated, with the confirmation and I can start exporting and publishing apps, but to me came 3 emails: welcome to the Apple Developer Program App Store connect good news! Your receipt for order — is ready But there isn’t any confirmation email, so how can I know if I can start posting my apps to App Store?
2
0
507
Dec ’21
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
580
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