Hey guys!
I wanted to place the circles along the screen, I took the screen size with UIScreen.main.bounds
, so that the circle did not come out of the edges of the screen, and yet it is still coming out! Would any of you be able to help me on how to make the circle stay within the edges of the screen, please?
I'm using SwiftUI and Swift Playgrounds.
struct ContentView: View {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
var body: some View {
Circle()
.foregroundColor(.purple)
.frame(width: 30, height: 30)
.position(
x: CGFloat.random(in: 0..<screenWidth),
y: CGFloat.random(in: 0..<screenHeight)
)
}
}