Currently, I am using CALayer
to achieve ripple effect. However, the transparent color in SFSymbol causes an issue.
I am using the following way to setup UIImageView
imageView.image = UIImage(systemName: "mic.circle.fill")
imageView.tintColor = UIColor.red
The above code yield the following outcome. (Green color is CALayer
with ripple animation)
Instead of transparent color, I would like the mic symbol to have solid white color. I try
imageView.image = UIImage(systemName: "mic.circle.fill")?.withRenderingMode(.alwaysOriginal)
It yields
Now, I get solid white color for mic symbol. However, the circle no longer solid red color.
I further try
imageView.image = UIImage(systemName: "mic.circle.fill")?.withRenderingMode(.alwaysOriginal).withTintColor(UIColor.red)
Now, it backs to the same problem again.
Do you have any idea, how can I have a SFSymbol, with
- Solid white for mic symbol
- Solid red for the filled circle
Thanks.
2
Answers
I can use the following code snippet
This code snippet is generated from 3rd party software: San Fransymbols
Add container view, set your imageView to .withRenderingMode(.alwaysTemplate), follow my example below… Set your container and your image view under your class controller:
now in viewDidLoad set constraints
This is the result: