Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you draw text shadow for SwiftUI's `Text` view?

Tags:

ios

swift

swiftui

With something like Text("Hello, World!"), how can I apply a soft dark text-shadow to it?

like image 586
garrettmaring Avatar asked Oct 19 '25 03:10

garrettmaring


1 Answers

Something like this?

Hello, World! with soft black shadow underneath

Text("Hello, World!")
    .font(.system(size: 30))
    .shadow(
        color: Color.primary.opacity(0.3), /// shadow color
        radius: 3, /// shadow radius
        x: 0, /// x offset
        y: 2 /// y offset
    )
like image 105
aheze Avatar answered Oct 20 '25 16:10

aheze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!