Post

Replies

Boosts

Views

Activity

Problems with Swift Playgrounds
Hello world! I was creating a playground with Swift Playgrounds, and I created a .swift files and should connect these files to ContentView(), but when I write that file name on ContentView() it tells me "Cannot find ... in scope". Does anyone know why this error and how to fix it? Thanks in advance from heart.
3
0
1.1k
Apr ’22
Error installing iOS 17.2 Simulator Xcode
Hello and happy new year to all! I've updated Xcode but I'm having a problem installing the iOS 17.2 Simulator. It's the 4th time I'm trying to download it, but it gives me this error: I've also download watchOS which is successfully installed, but I can't understand why only iOS is having some issues. If someone knows how to fix this issue, please help me, I'm unable to use Xcode without the iOS simulator :( Thanks in advance.
3
2
2.4k
Jan ’24
Build a website
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? And what is the WebKit, can I still use it to build web pages using SwiftUI? If someone has the right answer, please help me. Thanks.
2
0
3.0k
Aug ’22
Can I draw other shaper in Xcode?
Hello world, can I draw something else in Xcode, like when I write Circle(), it draws me a circle in the screen, or when I write Rectangle(), it appear a rectangle in the simulator... So are there other commands to draw some different shapes like this or I can elusively use these ones? Thank you.
1
0
482
Dec ’21
Change the position of a shape
Hi everyone, do you know the command to change the position of a shape. I want to change the position of a Rectangle and draw it to the right, this was the code that I tried: But it shows me that blue frame around and when I click on it (since it is a button) I can’t click outside that frame. Please help me… Thank you in advance ;)
5
0
2.3k
Dec ’21
Result of 'Text' initializer is unused
Hi, in this code it gives me the warning "Result of 'Text' initializer is unused" near Text("(Number)"). Does someone know what exactly mean this warning and how can I fix it? Thanks in advance struct NewView: View {     var body: some View {         Button {             tapped()         } label: {             Text("hello")         }     } }               func tapped() {     Text("\(Number)") } struct NewView_Previews: PreviewProvider {     static var previews: some View {         NewView()     } }
6
0
5.2k
Dec ’21
Create a button
Hello everyone. I would like to create a button in SwiftUI, which initially will display some text and with the click of the user will transform to a number (like initially the button displays "click me to add a number" and when I click on it'll immediately displays number "1" ). Can anyone help me with how to do this? Thanks
4
0
606
Dec ’21
Print something on the screen
Hello there! I would like to print the number 5 on the screen when I click the Button, but I don't know how I can do it... if I write print("5") it prints me the number 5 in the debug area of Xcode. Can someone help me to figure out this? Here's may code Thanks a lot Button {         } label: {             ZStack {                 Circle()                     .frame(width: 90, height: 90)                     .foregroundColor(Color(.systemBlue))                     .opacity(0.5)                                     Text("5")                     .font(.largeTitle)                     .bold()                     .foregroundColor(.black)             }             .frame(width: 90, height: 90)         }
9
0
1.1k
Jan ’22
Add Text to an animated object
Hello guys, everything was working perfectly but I can't do a thing please help me. I was trying to put into this Rectangle some text , I've tried several lines of code but I can't put the Text INTO the rectangle. Can someone help me? Here's the code import SwiftUI import PlaygroundSupport struct ContentView: View {     @State  var flipped = false      var body: some View {                      Group {                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(self.flipped ? .red : .orange)                     .padding()                     .rotation3DEffect(self.flipped ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         self.flipped.toggle()                                              }             }                          }     } PlaygroundPage.current.setLiveView(ContentView())
5
0
1.1k
Jan ’22
Add Text to an animated object
Hello guys, everything was working perfectly but I can't do a thing please help me. I was trying to put into this Rectangle some text , I've tried several lines of code but I can't put the Text INTO the rectangle. Can someone help me? Here's the code import SwiftUI import PlaygroundSupport struct ContentView: View {     @State  var flipped = false      var body: some View {                      Group {                 RoundedRectangle(cornerRadius: 20)                     .frame(width: 140, height: 170)                     .foregroundColor(self.flipped ? .red : .orange)                     .padding()                     .rotation3DEffect(self.flipped ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))                     .animation(.default)                      .onTapGesture {                         self.flipped.toggle()                                              }             }                          }     } PlaygroundPage.current.setLiveView(ContentView())
1
0
565
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
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
703
Jan ’22