Post

Replies

Boosts

Views

Activity

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
635
Jan ’22
How to fix these errors?
Hello there! I want to create a cards game, and I'm creating it following the Stanford University's tutorial. I followed the video step by step but there is a warning that In the video doesn't appear. Can someone help me to fix it? Here's the link of the video: [https://www.youtube.com/watch?v=oWZOFSYS5GE&t=671s) This is my code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     var body: some View {         VStack {                 LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                     ForEach(viewModel.cards) { card in                         CardView(card: card)                             .aspectRatio(aspectRatio, contentMode: .fit) // here's the first error which says "Cannot convert value of type '(CGFloat?, ContentMode) -> some View' to expected argument type 'CGSize'"                     }                 }                 .padding()                 .foregroundColor(Color(.systemTeal))                                  Spacer()                 Button {                     emojiCount += 1                     if emojiCount == 10 {                         aspectRatio = 9/3                     } ì                     if emojiCount > 17 {                         print("Card finished")                     }                 } label: {                     Text("Add Card")                 }             }         }     } struct CardView: View {     let card: MemoryGame<String>.Card          var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }     } } struct ContentView_Previews:     PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //here's the second error which says "Cannot find 'game' in scope"     } }
14
0
1.9k
Aug ’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
1.1k
Feb ’22
Need a little help with my code
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.
2
0
501
Feb ’22
Same content in 2 cards
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())
2
0
3.7k
Mar ’22
Expand the circle throughout the screen in SwiftUI
Hi there! I'm trying to build something in SwiftUI and I need a help on it. I want the orange circle to scale and expand, and fill the entire screen, whenI click on it. Here's my code: import SwiftUI struct ContentView: View {     var body: some View {        Circle()             .frame(width: 120, height: 120)             .foregroundColor(.orange)     } } Thank you.
1
0
1.7k
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
688
Apr ’22
Xcode issue
Hello everyone! I recently updated my Mac to macOS Ventura, everything was updated as expected, but I'm having a problem with Xcode, I also updated Xcode, but when I clicked on it for opening it, a message appeared which says that "In order to use Xcode, you need to update to the latest version" (despite having already updated it), so, when I go on App Store for updating it again, it already says me to open, and there isn't the Update option. I'm troubling with this problem... please if anyone knows how to fix it, help me. Thank you.
4
0
3.3k
Jun ’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())
Replies
2
Boosts
0
Views
635
Activity
Jan ’22
How to fix these errors?
Hello there! I want to create a cards game, and I'm creating it following the Stanford University's tutorial. I followed the video step by step but there is a warning that In the video doesn't appear. Can someone help me to fix it? Here's the link of the video: [https://www.youtube.com/watch?v=oWZOFSYS5GE&t=671s) This is my code: import SwiftUI struct ContentView: View {     let viewModel: EmojiMemoryGame     var body: some View {         VStack {                 LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) {                     ForEach(viewModel.cards) { card in                         CardView(card: card)                             .aspectRatio(aspectRatio, contentMode: .fit) // here's the first error which says "Cannot convert value of type '(CGFloat?, ContentMode) -> some View' to expected argument type 'CGSize'"                     }                 }                 .padding()                 .foregroundColor(Color(.systemTeal))                                  Spacer()                 Button {                     emojiCount += 1                     if emojiCount == 10 {                         aspectRatio = 9/3                     } ì                     if emojiCount > 17 {                         print("Card finished")                     }                 } label: {                     Text("Add Card")                 }             }         }     } struct CardView: View {     let card: MemoryGame<String>.Card          var body: some View {         ZStack {             let shape = RoundedRectangle(cornerRadius: 20)             if card.isFaceUp {                 shape.fill().foregroundColor(.white)                 shape.stroke(lineWidth: 3)                 Text(card.content).font(.system(size: 50))             } else {                 shape.fill(.orange)             }         }     } } struct ContentView_Previews:     PreviewProvider {         static var previews: some View {             ContentView(viewModel: game) //here's the second error which says "Cannot find 'game' in scope"     } }
Replies
14
Boosts
0
Views
1.9k
Activity
Aug ’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!
Replies
3
Boosts
0
Views
1.1k
Activity
Feb ’22
Create own assets
Hi everyone, can anyone tell me how can I create images for Xcode assets. Because now I want to create my own image not using the readymade. Thank you!
Replies
6
Boosts
0
Views
638
Activity
Feb ’22
UIKit and SwiftUI
Hi everyone, can anyone explain me the difference between SwiftUI and UIKit? Thank you.
Replies
4
Boosts
0
Views
1.1k
Activity
Feb ’22
SceneKit in Swift Playgrounds
Hi everyone, I want to use SceneKit in Swift Playgrounds, or import the Xcode project with SceneKit into Swift Playgrounds. Is it possible?
Replies
2
Boosts
0
Views
1.6k
Activity
Feb ’22
Is my Feedback visible to others?
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.
Replies
2
Boosts
0
Views
968
Activity
Feb ’22
Need a little help with my code
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
2
Boosts
0
Views
501
Activity
Feb ’22
Same content in 2 cards
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())
Replies
2
Boosts
0
Views
3.7k
Activity
Mar ’22
Expand the circle throughout the screen in SwiftUI
Hi there! I'm trying to build something in SwiftUI and I need a help on it. I want the orange circle to scale and expand, and fill the entire screen, whenI click on it. Here's my code: import SwiftUI struct ContentView: View {     var body: some View {        Circle()             .frame(width: 120, height: 120)             .foregroundColor(.orange)     } } Thank you.
Replies
1
Boosts
0
Views
1.7k
Activity
Apr ’22
Use fonts in SwiftUI
Hello there! Does anyone know how to apply Apple's default fonts to text in SwiftUI?
Replies
5
Boosts
0
Views
1.6k
Activity
Apr ’22
Set an image as the background in SwiftUI
Hello there! I would like to set an image as the background of my project in SwiftUI, but I have no idea how it is done. Could anyone help me to figure out this? I am using Swift Playgrounds and SwiftUI framework.
Replies
1
Boosts
0
Views
799
Activity
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.
Replies
1
Boosts
0
Views
688
Activity
Apr ’22
How to put in casual position objects in SwiftUI
Hey there! I have a Circle, and I would like to create many on this circle and display them in random position on the screen. Is it possible? Thanks in advance.
Replies
5
Boosts
0
Views
1.7k
Activity
Apr ’22
Xcode issue
Hello everyone! I recently updated my Mac to macOS Ventura, everything was updated as expected, but I'm having a problem with Xcode, I also updated Xcode, but when I clicked on it for opening it, a message appeared which says that "In order to use Xcode, you need to update to the latest version" (despite having already updated it), so, when I go on App Store for updating it again, it already says me to open, and there isn't the Update option. I'm troubling with this problem... please if anyone knows how to fix it, help me. Thank you.
Replies
4
Boosts
0
Views
3.3k
Activity
Jun ’22