import SwiftUI
struct LoginScreen: View {
var body: some View {
NavigationView {
ZStack {
LinearGradient(colors: [.blue, .black], startPoint: .topLeading, endPoint: .bottomTrailing)
Circle()
.scale(1.3)
.foregroundColor(.white.opacity(0.6))
Circle()
.scale(1.7)
.foregroundColor(.white.opacity(0.3))
}
.navigationBarHidden(true)
}
.edgesIgnoringSafeArea(.all)
}
}
I wanna add a gradient like my background to circle. When I use
.background( LinearGradient(colors: [.blue, .black], startPoint: .topLeading, endPoint: .bottomTrailing))
its going to all black.
When you want to change the appearance(color, gradient...) of a Shape
, use .fill
instead of .background
.
Circle()
.fill(LinearGradient(colors: [.blue, .black], startPoint: .topLeading, endPoint: .bottomTrailing))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.