Post

Replies

Boosts

Views

Activity

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
Password Animation
Hello guys! I need a little help. I want to create a password animation using SwiftUI, but can't understand how, if you can help me I'll appreciate it a lot. For example when I write something, after I finished the word, it'll turn into points. I hope you understand what I mean. Thanks in advance.
0
0
809
Oct ’22
No profiles founded
Hi friends! I was developing an app, everything was working OK, but when I played the app on my iPhone connecting it via cable to the Mac an error has appeared and it says "The operation couldn't be completed. Unable to log in with account ... " "No profiles for ... were found: Xcode couldn't find any iOS app Development provisioning devices matching ..." and I'm not able to try it on my iPhone. Any suggestion or idea to fix these errors?
0
0
736
Nov ’22
URGENT!
Hey guys, I'm having a huge problem and can't understand how to fix it. I was trying to recreate an Xcode app project with a Xcode Playground, now the point is that in Xcode Project on the side of the screen there are the options to add files. Like this: And in the Playground it is like this: But here, when I add the Swift Files under Shared Sources, and create the ContentView() in Main - Xcode Playground, it says me that it can't find the Helicopter, Pixel, Obstacle, so it can't find the Shared Recourses' files. Here's all the code. ContentView(Main): import SwiftUI import PlaygroundSupport struct ContentView: View { @State private var heliPosition = CGPoint(x:100, y: 100) @State private var obstPosition = CGPoint(x:1000, y: 300) @State private var isPaused = false @State private var score = 0 @State var timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect() var body: some View { GeometryReader { geo in ZStack{ Helicopter() .position(self.heliPosition) .onReceive(self.timer) {_ in self.gravity() } Obstacle() .position(self.obstPosition) .onReceive(self.timer) {_ in self.obstMove() } Text("\(self.score)") .foregroundColor(.white) .position(x: geo.size.width - 100, y: geo.size.height / 10 ) self.isPaused ? Button("Resume") { self.resume() } : nil } .frame(width: geo.size.width, height: geo.size.height) .background(Color.black) .gesture( TapGesture() .onEnded{ withAnimation{ self.heliPosition.y += 100 } }) .onReceive(self.timer) { _ in self.collisionDetection(); self.score += 1 } } .edgesIgnoringSafeArea(.all) } func gravity() { withAnimation{ self.heliPosition.y -= 20 } } func obstMove() { if self.obstPosition.y > 0 { withAnimation{ self.obstPosition.y -= 20 } } else { self.obstPosition.x = 1000 self.obstPosition.y = CGFloat.random(in: 0...500) } } func pause() { self.timer.upstream.connect().cancel() } func resume() { self.timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect() self.obstPosition.x = 1000 self.heliPosition = CGPoint(x: 100, y: 100) self.isPaused = false self.score = 0 } func collisionDetection() { if abs(heliPosition.x - obstPosition.x) < (25 + 10) && abs(heliPosition.y - obstPosition.y) < (25 + 100) { self.pause() self.isPaused = true } } } PlaygroundPage.current.setLiveView(ContentView()) Pixel: import SwiftUI public struct Pixel: View { let size: CGFloat let color: Color public var body: some View { Rectangle() .frame(width: size, height: size) .foregroundColor(color) } } Helicopter: import SwiftUI public struct Helicopter: View { let rows = 5 let columns = 5 let size: CGFloat = 10 let heliBlocks: [[Color]] = [[.gray,.gray,.gray,.gray,.gray], [.clear,.clear,.green,.clear,.clear], [.green,.green,.green,.green,.gray], [.clear,.clear,.green,.green,.green], [.clear,.clear,.gray,.clear,.gray]] public var body: some View { VStack (spacing: 0) { ForEach((0...self.rows - 1), id: \.self) { row in HStack (spacing: 0) { ForEach((0...self.columns - 1), id: \.self) { col in VStack (spacing: 0) { Pixel(size: self.size, color: self.heliBlocks[row][col]) } } } } } } } Obstacle: import SwiftUI public struct Obstacle: View { let width: CGFloat = 20 let height: CGFloat = 200 public var body: some View { Rectangle() .frame(width: width, height: height) .foregroundColor(Color.green) } } Guys please, if anyone knows how to fix this, please help me. I will be grateful to you.
0
0
711
Apr ’23
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
483
Dec ’21
Flip animation in SwiftUI
Hello everyone, I would like to a flip animation, so that when I press on the rectangle it will flip to other side (like in a cards game) How can I do that? Thank you Here's my code: import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {                      Group {                 Button {                                      } label: {                     Rectangle()                         .frame(width: 140, height: 170)                         .foregroundColor(Color(.systemTeal))                         .cornerRadius(20)                 }             }     } } PlaygroundPage.current.setLiveView(ContentView())
1
0
3.0k
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
566
Jan ’22
Move according to the button
Hello there! I would like to move the object according to the button press. In this code, I have the circle and I like to move it down if I press the down button. Can anyone tell me how can I do this? Thanks. import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {         Circle()             .frame(width: 80, height: 80)         Spacer(minLength: 20)             Button{             } label: {                 Image(systemName: "arrowtriangle.down.circle.fill")                     .resizable()                     .foregroundColor(.blue)                     .frame(width: 70, height: 70)                     .padding()             }     } } PlaygroundPage.current.setLiveView(ContentView())
1
0
1.2k
Feb ’22
What's wrong here?
Hello everyone, I'm trying to make particle effect in SwiftUI, following a YouTube tutorial and this is what I made, despite I wrote the same code as the video, it gives me this error (which doesn't appear in the video). So can anyone tell me what I did wrong? Here's my code: And the link for the tutorial: https://www.youtube.com/watch?v=oj4HEqkDvBY import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {         Text("Hello, world!")     } } struct ParticleEffect: ViewModifier {     let count: Int     let duration: Double = 2.0     @State var time: Double = 0.0     func body(content: Content) -> some View {         let animation = Animation.linear(duration: duration)             .repeatForever(autoreverses: false)         return  ZStack {             ForEach(0..<count) { index in                 content                     .scaleEffect(CGFloat((duration-self.time)/duration))                     .modifier(ParticleMotion(time: self.time)) // ERROR: Cannot find 'ParticleMotion' in scope                     .opacity((duration-self.time)/duration)                     .animation(animation.delay(Double.random(in: 0..<self.duration)))                     .blendMode(.plusLighter)             }             .onAppear {                 withAnimation() {                     self.time = duration                 }             }         }     } } PlaygroundPage.current.setLiveView(ContentView())
1
0
477
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.
1
0
581
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