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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi there!
Does anyone know if the flight for the Special Event at Apple Park can be paid by Apple?
Anyone who knows how it works, please help me.
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.
Hi guys,
is Swift Playgrounds same as Xcode, I mean the code that I write in Xcode I can paste it into Swift Playgrounds?
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.
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.
Hello everyone!
I was putting a figure in my code when I was interrupted by this error that says "Extra argument in call", what does this sentence mean and how can I fix it?
Thanks!
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 ;)
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()
}
}
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
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)
}
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())
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())
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())
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()
}