TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Draw a border on image with cropped out background

Forums > SwiftUI

Hello guys,

I want to draw a white border on an image of which I have previously removed its background. Now it has a non-square form.

.shadow handles this like a pro: the shadow is applied along its complex borders.

But .border still adds a sqaure.

Here is an image: https://ibb.co/RH97TfQ

Any ideas how to add a border along its "real form"?

Help is much appreciated 🙏

Best

2      

The .border() modifier can't do complex shapes like that. I would create a second instance of your image that is transparent except for your white border and then use the .overlay() modifier to layer your transparent border over your battery image.

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.