NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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)

   

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)
            }

1      

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

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until October 1st.

Click to save your free spot now

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

Reply to this topic…

You need to create an account or log in to reply.

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.