sparrowcode / AlertKit

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

Home Page:https://sparrowcode.io/frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color for icon in SwiftUI

derech1e opened this issue · comments

Is your feature request related to a problem? Please describe.
Please add custom color support to icons in SwiftUI.

Describe the solution you'd like
Something, where you can define the color of the .error icon animation. It would be pretty nice!

You can use method with SPAlertView parameter, before set tint color to view.

How can I set the tint color?

SPAlertView(title: "Test", message: "Test1", preset: .done).present(haptic: .success) { print("a") }

This also not work:

let alert = SPAlertView(title: "a", message: "b", preset: .error)
alert.tintColor = .red
alert.present()

@ivanvorobei I don't get it. Even when I set the tint to the whole Stack it won't change the icon color.

Try set tint for icon color and template rendering mode. Also you can set image with original rendering mode and specific color.

I can't set the renderingMode. It throws an error.

                        let alert = SPAlertView(title: "", message: addLoogbookEntryVM.brokenValues[0].message, preset: .error)
                        alert.duration = 3.5
                        alert.dismissByTap = true
                        alert.iconView?.tintColor = .red
                        alert.tintColor = .red
                        alert.iconView?.largeContentImage?.renderingMode = .alwaysOriginal
                        alert.present()

@ivanvorobei

You should set image with rendering mode.

You should set image with rendering mode.

But when I set the image I lose the animation. Right?

Can you give me a little code snippet?

Sorry, I founded bug. Now you can change color simple with tint. Also I added Colors section in Readme.

Please, update to 4.0.1 version

Ok, but still not working for me :/

let alert = SPAlertView(title: "", message: "Test", preset: .custom(UIImage(systemName: "pencil.and.outline")!.withRenderingMode(.alwaysTemplate)))
                        alert.iconView?.tintColor = .red
                        alert.duration = 3.5
                        alert.dismissByTap = true
                        alert.present()

This is my code, that don't work.

Are you sure about upgrade to new version? I tested your code, and it work

Simulator Screen Shot - iPhone 13 Pro - 2021-12-24 at 10 20 43

Are you sure about upgrade to new version? I tested your code, and it work

Simulator Screen Shot - iPhone 13 Pro - 2021-12-24 at 10 20 43

Ok, I am sorry. I thought I updated to the last version but for some reason it wasn't the case. Now it works :)
Thank you!