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

SOLVED: Displaying a system image in a different color than the text

Forums > SwiftUI

A seemingly simple question but I can't figure it out.

I have the following label for a button

I'd like to display the image in Orange, and the text in White. I know that I can use foregroundcolor to change the entire lable but I only want to change the color of the image.

Any ideas?

Thank you!

Label("Here is some text, I just want to display the bubble image in Orange. Please help :) .", systemImage: "questionmark.bubble")
            }
                    .font(.system(size: 16, weight: .light, design: .rounded))
                    .multilineTextAlignment(.center)

1      

Hi! Use this initializer for label

 Label {
                Text("Here is some text, I just want to display the bubble image in Orange. Please help :) .")
                    .font(.system(size: 16, weight: .light, design: .rounded))
                    .multilineTextAlignment(.center)
            } icon: {
                Image(systemName: "questionmark.bubble")
                    .foregroundColor(.orange)
            }

2      

Awesome. Thank you again @ygeras :))))

1      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.