LinearGradient
Gradient
의 colors에 원하는 Color
를 배열로 넣으면 linear gradient를 사용할 수 있다.
gradiant
LinearGradient(
gradient: Gradient(
colors: [
Color(#colorLiteral(red: 0.2901960902, green: 0.3196078537, blue: 0.4823529426, alpha: 1)),
Color(#colorLiteral(red: 0.1215686287, green: 0.1294117719, blue: 0.250980407, alpha: 1))
]
),
startPoint: .top,
endPoint: .bottom
)
init(gradient:startPoint:endPoint:)
init(colors:startPoint:endPoint:)
init(stops:startPoint:endPoint:)
stop
stops
를 이용해 원하는 위치에 gradient를 지정할 수 있다.
let stops = [
Gradient.Stop(color: Color.green, location: 0.0),
Gradient.Stop(color: Color.green, location: 0.33),
Gradient.Stop(color: Color.blue, location: 0.33),
Gradient.Stop(color: Color.blue, location: 0.66),
Gradient.Stop(color: Color.red, location: 0.66),
Gradient.Stop(color: Color.red, location: 1.0)
]
LinearGradient(
stops: stops,
startPoint: .trailing,
endPoint: .leading
)