Sunday, 16 December 2018

Named colors via storyboard

For my MacOS app, I created a colors Asset catalog. The Deployment target for my project is 10.11.

When I set colors at the storyboard, I can choose from the colors asset. But when I try to set one of the named colors programmatically, I need to wrap it in

if #available(OSX 10.13, *) {
   view.backgroundColor = NSColor(named: "someColor")
} else {
   // Fallback on earlier versions
}

ORIGINAL QUESTION:

So the question is why I'm not getting any warnings for choosing those colors via the storyboard?

I guess I need to replace them with a custom color, or my app will crash on OS < 10.13, but I would expect the storyboard not to let me choose those colors because of the deployment target..

EDITED:

So the question is what happens when I'm using those colors via Storyboard? Would it crash the app? or maybe the storyboard can handle named colors even for OS versions < 10.13 ? Because I tried to use the named colors via the Storyboard, and I installed the app on a Mac with OS 10.12, and the app worked just fine. So I'm wondering what's the reason for that..

P.S This question is also relevant to iOS, where the min version for named colors is iOS 11



from Named colors via storyboard

No comments:

Post a Comment