UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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 RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.