Posts

Post not yet marked as solved
1 Replies
180 Views
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.                         }                     }                 }             }         }     } }
Posted Last updated
.
Post marked as solved
4 Replies
346 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
184 Views
Hello everyone! I had a question about the Apple’s WWDC Special event, hope someone can resolve my doubts. For taking part of this event, will the event for invites be online or we have to go at Cupertino? Because I read some articles that says the event for developers will in-person. Quindi sono un po’ confusa, per favore aiutatemi se riuscite ;)
Posted Last updated
.
Post not yet marked as solved
3 Replies
212 Views
Hello there! I'm trying to create a button with a neumorphic animation using SwiftUI, with a smooth animation when the user taps it. Something like this: Can someone help me to figure out this, please? Thanks!
Posted Last updated
.
Post marked as solved
5 Replies
226 Views
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.
Posted Last updated
.
Post not yet marked as solved
1 Replies
170 Views
Hi there! I have a public structure and I called it in my ContentView, but I can't understand where to punt the var/let. I try to put them before "var body: some view" but it gives me these errors.
Posted Last updated
.
Post not yet marked as solved
2 Replies
224 Views
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.
Posted Last updated
.
Post marked as solved
1 Replies
144 Views
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.
Posted Last updated
.
Post not yet marked as solved
3 Replies
350 Views
Hello world! I'm planning to participate in this year's WWDC22. And I have a question: for participating at the Challenge I need to provide Educational Supervisor's Contact Information, can I enter the information of my teacher, who is also my class coordinator?
Posted Last updated
.
Post marked as solved
1 Replies
180 Views
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.
Posted Last updated
.
Post marked as solved
5 Replies
250 Views
Hello there! Does anyone know how to apply Apple's default fonts to text in SwiftUI?
Posted Last updated
.
Post not yet marked as solved
0 Replies
126 Views
Hi there! I want to attach 2 objects in SwiftUI when they'll near. import SwiftUI struct ContentView: View {     @State private var dragOffset: CGSize = .zero     @State private var position: CGSize = .zero     var body: some View{         Circle()             .frame(width: 140, height: 140)             .foregroundColor(.green)             .position(x: 150, y: 90)             .offset(x: dragOffset.width + position.width, y: dragOffset.height)             .gesture(DragGesture()                         .onChanged({ (value) in                              self.dragOffset = value.translation                         })             )         Circle()             .frame(width: 140, height: 140)             .foregroundColor(.blue)             .position(x: 500, y: 210)         Circle()             .frame(width: 140, height: 140)             .foregroundColor(.orange)             .position(x: 90, y: 70)     } } In my code I want to stick the green circle with one of the other 2, when it is close to them. Can anyone help me figure out this? Thanks in advance.
Posted Last updated
.
Post not yet marked as solved
1 Replies
202 Views
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?
Posted Last updated
.