Post

Replies

Boosts

Views

Activity

Where to put animation
Hello everyone! Can someone tell me where to put animation when I use LazyVGrid, please? Here’s my code: struct MyEmoji : Hashable { var char: String var num: Int } struct ContentView39: View { var emojis : [MyEmoji] = [MyEmoji(char: "🐶", num: 0), MyEmoji(char: "🐱", num: 1), MyEmoji(char: "🐱", num: 2), MyEmoji(char: "🦊", num: 3), MyEmoji(char: "🦁", num: 4), MyEmoji(char: "🐝", num: 5), MyEmoji(char: "🐼", num: 6), MyEmoji(char: "🐷", num: 7), MyEmoji(char: "🐮", num: 8)] var body: some View { LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) { ForEach(emojis, id: \.self, content: { emoji in emojiView(content: emoji.char) }) } } Thanks in advance.
1
0
599
Mar ’22
Attach magnetically an object in SwiftUI
Hello everyone! Can I attach one object to another using a magnate animation in SwiftUI? For example In the code below I want the blue square to attach with the red one, when I drag it near it. import PlaygroundSupport import SwiftUI struct ContentView:  View {     @State private var isDragging = false     @State private var dragOffset: CGSize = .zero     @State var position: CGSize = .zero     @State private var hovered = false     var body: some View {         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.red)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.blue)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)             .animation(.default, value: hovered)             .offset(x: dragOffset.width + position.width, y: dragOffset.height + position.height)             .gesture(                 DragGesture()                     .onChanged({ value in                         self.dragOffset = value.translation                     })                     .onEnded({ value in                         self.position.width += value.translation.width                         self.position.height += value.translation.height                         self.dragOffset = .zero                     })             )     } } PlaygroundPage.current.setLiveView(ContentView()) Thanks.
0
0
329
Mar ’22
Attach magnetically an object in SwiftUI
Hello guys! Can I attach one object to another using a magnate animation in SwiftUI? For example In the code below I want the blue square to attach with the red one, when I drag it near it. Here's. my code: import PlaygroundSupport import SwiftUI struct ContentView:  View {     @State private var isDragging = false     @State private var dragOffset: CGSize = .zero     @State var position: CGSize = .zero     @State private var hovered = false     var body: some View {         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.red)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.blue)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)             .animation(.default, value: hovered)             .offset(x: dragOffset.width + position.width, y: dragOffset.height + position.height)             .gesture(                 DragGesture()                     .onChanged({ value in                         self.dragOffset = value.translation                     })                     .onEnded({ value in                         self.position.width += value.translation.width                         self.position.height += value.translation.height                         self.dragOffset = .zero                     })             )     } } PlaygroundPage.current.setLiveView(ContentView()) If anyone knows how to do this, please help me. Thanks
2
0
402
Mar ’22
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
Attach objects in SwiftUI
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.
0
0
423
Apr ’22
WWDC22 Special Event
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 ;)
0
0
1.1k
May ’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
855
Jun ’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
Display multiple overlays
Hello guys, Is it possible to display different overlays on a text in SwiftUI? If someone knows how to do it, please help me with an example. I am in trouble with it. Thank you very much!
Replies
0
Boosts
0
Views
366
Activity
Mar ’22
Unable to prepare iPhone for development
Hi everyone, I want to try my Xcode project on my iPhone, but I can't because of an error, which says "Unable to prepare iPhone for development". Can someone help me to try my app on my iPhone and fix this error? Thank you!
Replies
2
Boosts
0
Views
875
Activity
Mar ’22
Where to put animation
Hello everyone! Can someone tell me where to put animation when I use LazyVGrid, please? Here’s my code: struct MyEmoji : Hashable { var char: String var num: Int } struct ContentView39: View { var emojis : [MyEmoji] = [MyEmoji(char: "🐶", num: 0), MyEmoji(char: "🐱", num: 1), MyEmoji(char: "🐱", num: 2), MyEmoji(char: "🦊", num: 3), MyEmoji(char: "🦁", num: 4), MyEmoji(char: "🐝", num: 5), MyEmoji(char: "🐼", num: 6), MyEmoji(char: "🐷", num: 7), MyEmoji(char: "🐮", num: 8)] var body: some View { LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) { ForEach(emojis, id: \.self, content: { emoji in emojiView(content: emoji.char) }) } } Thanks in advance.
Replies
1
Boosts
0
Views
599
Activity
Mar ’22
Attach magnetically an object in SwiftUI
Hello everyone! Can I attach an object with a magnete animation to the other in SwiftUI? Please show me that with a simple example. Thank you in advance.
Replies
2
Boosts
0
Views
725
Activity
Mar ’22
Attach magnetically an object in SwiftUI
Hello everyone! Can I attach one object to another using a magnate animation in SwiftUI? For example In the code below I want the blue square to attach with the red one, when I drag it near it. import PlaygroundSupport import SwiftUI struct ContentView:  View {     @State private var isDragging = false     @State private var dragOffset: CGSize = .zero     @State var position: CGSize = .zero     @State private var hovered = false     var body: some View {         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.red)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.blue)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)             .animation(.default, value: hovered)             .offset(x: dragOffset.width + position.width, y: dragOffset.height + position.height)             .gesture(                 DragGesture()                     .onChanged({ value in                         self.dragOffset = value.translation                     })                     .onEnded({ value in                         self.position.width += value.translation.width                         self.position.height += value.translation.height                         self.dragOffset = .zero                     })             )     } } PlaygroundPage.current.setLiveView(ContentView()) Thanks.
Replies
0
Boosts
0
Views
329
Activity
Mar ’22
Attach magnetically an object in SwiftUI
Hello guys! Can I attach one object to another using a magnate animation in SwiftUI? For example In the code below I want the blue square to attach with the red one, when I drag it near it. Here's. my code: import PlaygroundSupport import SwiftUI struct ContentView:  View {     @State private var isDragging = false     @State private var dragOffset: CGSize = .zero     @State var position: CGSize = .zero     @State private var hovered = false     var body: some View {         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.red)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)         RoundedRectangle(cornerRadius: 20)             .foregroundColor(.blue)             .frame(width: 100, height: 100)             .position(x: 400, y: 350)             .animation(.default, value: hovered)             .offset(x: dragOffset.width + position.width, y: dragOffset.height + position.height)             .gesture(                 DragGesture()                     .onChanged({ value in                         self.dragOffset = value.translation                     })                     .onEnded({ value in                         self.position.width += value.translation.width                         self.position.height += value.translation.height                         self.dragOffset = .zero                     })             )     } } PlaygroundPage.current.setLiveView(ContentView()) If anyone knows how to do this, please help me. Thanks
Replies
2
Boosts
0
Views
402
Activity
Mar ’22
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?
Replies
1
Boosts
0
Views
1.1k
Activity
Apr ’22
Educational Supervisor’s Contact Information
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?
Replies
3
Boosts
0
Views
1.4k
Activity
Apr ’22
Attach objects in SwiftUI
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.
Replies
0
Boosts
0
Views
423
Activity
Apr ’22
Where to put variables/constants
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.
Replies
1
Boosts
0
Views
724
Activity
Apr ’22
How to export an Xcode project into a Swift Playgrounds playground
Hello guys! Does anyone know how to export an Xcode app project in na Swift Playgrounds' playground?
Replies
0
Boosts
0
Views
663
Activity
Apr ’22
Neumorphic Button SwiftUI
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!
Replies
3
Boosts
0
Views
1.1k
Activity
May ’22
WWDC22 Special Event
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 ;)
Replies
0
Boosts
0
Views
1.1k
Activity
May ’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.                         }                     }                 }             }         }     } }
Replies
1
Boosts
0
Views
855
Activity
Jun ’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:
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’22