Text+Ex.swift 894 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // Text+Ex.swift
  3. // Pods
  4. //
  5. // Created by 100Years on 2025/3/13.
  6. //
  7. import SwiftUI
  8. public extension Text {
  9. func gradientForeground(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint) -> some View {
  10. self
  11. .overlay(
  12. LinearGradient(
  13. gradient: Gradient(colors: colors),
  14. startPoint: startPoint,
  15. endPoint: endPoint
  16. )
  17. .mask(self)
  18. )
  19. }
  20. }
  21. public extension View {
  22. func gradientForeground(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint) -> some View {
  23. self
  24. .overlay(
  25. LinearGradient(
  26. gradient: Gradient(colors: colors),
  27. startPoint: startPoint,
  28. endPoint: endPoint
  29. )
  30. .mask(self)
  31. )
  32. }
  33. }