SwiftUI용 OKLCH 그라디언트
이는 SwiftUI 내장 LinearGradient, RadialGradient, EllipticalGradient 및 AngularGradient 쉐이프 스타일을 대체하는 드롭인으로, OKLCH 색상 혼합을 활용하여 시각적으로 더 매력적인 그라디언트를 만듭니다.
iOS 17의 Shader API를 사용하여 구현되었으며, 이는 개인 API에 의존하지 않고 커스텀 렌더링으로 쉐이프 스타일을 작성하는 유일한 방법인 것으로 보입니다.
SPM을 사용하여 설치:
dependencies: [
.package(url: "https://github.com/fwrs/OKLCHGradient.git", .upToNextMajor(from: "1.0.9"))
]
그라디언트 구조체 이름 앞에 OKLCH를 붙여서 사용하세요:// changeRectangle()
.background(LinearGradient(
colors: [.blue, .yellow],
startPoint: .leading,
endPoint: .trailing
))
// to
import OKLCHGradient
Rectangle()
.background(OKLCHLinearGradient(
colors: [.blue, .yellow],
startPoint: .leading,
endPoint: .trailing
))
그리고 차이를 즐기세요:
[!NOTE]
현재 AnyGradient 구조체를 OKLCH 그라디언트에 전달하는 것은 불가능합니다. 공개 API를 통해 AnyGradient에서 색상 정지를 읽는 방법이 없기 때문입니다. 이 기능은 애플 자체 내장 그라디언트에만 제한됩니다.
--- Tranlated By Open Ai Tx | Last indexed: 2026-01-10 ---