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())
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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.
Hello there!
Does anyone know how to apply Apple's default fonts to text 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.
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.
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.
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.
Hi developers!
Does anyone know an app to make a short animated film like this https://youtu.be/a4PraWW82_A, which is also free?
I used Procreate before, but there is the layer limit and since my video is a little long I need more layouts :(
thanks in advance
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?
Hello everyone,
I was working on a Xcode playground, and unexpectedly it appeared an error that I can't understand how to fix.
Here's the error that I'm facing.
Does someone know how to fix it?
Thanks in advance ;)
Hi there,
I'm studying SwiftUI on my own, but unfortunately I'm still not able to write complex lines of code, or even code an app independently, which is very frustrating for me.
I love coding, it's a way to express my creativity.
I already have a lot of ideas, but I can't put them into practice because I feel like I don't have learned enough about this programming language.
Can any of you suggest me some free courses or other resources that have also helped you in your first steps with coding?
Hi everyone!
import SwiftUI
struct ContentView: View {
let screenHeight = UIScreen.main.bounds.height
let letters: [String] = ["A", "B"]
@State private var yOffset: CGFloat = 0.0
var body: some View {
ForEach(letters, id: \.self) { letter in
Text(letter)
.padding()
.font(.largeTitle)
.offset(x: 0, y: yOffset)
.animation(Animation.linear(duration: 5.0).repeatForever(autoreverses: false))
.onAppear {
yOffset = screenHeight - 90
}
}
}
}
I would like in this code, the letters to fall from the beginning of the screen to its end, I have the size of screen's height, but actually I can't understand how I can I use it, until the letters can start from the beginning of the screen. And I would also like that once they reach the bottom, they start falling again...
I can't understand how this effect can be achieved, is there anyone who can help me?
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 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.