Is there a practical difference between setting a color to UIColor.clear and nil? - Swift

Viewed 321

Is there a difference between these two statements?

view.backgroundColor = .clear

view.backgroundColor = nil

I always use the latter, but I mostly see people using UIColor.clear whenever they want to make the background clear. Is there actually a difference?

1 Answers

No there isn't as the default is transpartent = clear see in Docs

@NSCopying var backgroundColor: UIColor? { get set }

Changes to this property can be animated. The default value is nil, which results in a transparent background color.

Related