macOS Programming: Working with Dark Theme and Building a BMI Calculator

Welcome to another macOS programming tutorial! In the previous post we made our introductory steps on macOS programming world as we discussed about fundamental concepts. In this tutorial, we are going to explore and unveil new interesting things that would be necessary to anyone who wants to make their way to macOS development.

So, if you have gone through the previous post, then you already know that the main focus was on window controllers and windows, panels, loading and presenting additional windows, and more. However, there is one thing that was not discussed at all (intentionally), and that is the dark theme that was first presented on macOS Mojave (10.14), and what actions a developer has to do so an app works properly in both dark and light content. Dark theme gives a great look-and-feel to macOS which all developers and single users have undoubtedly loved. But despite its nice appearance, it inevitably puts developers into additional efforts in order to provide images, colors and other assets for both dark and light modes. The first goal here is to see how to provide different sets of assets so an app can work well in both modes.

Besides that, I am going to show you how to create a preferences window. That window that many apps provide for making settings and configurations. See for example the Xcode > Preferences or Safari > Preferences window and you will understand what I am talking about. Of course, our preferences window here is going to be extremely simple, but you will get some really valuable lessons on how to deal with preferences in general. A few important steps and considerations hide behind the making of preferences, and you will get to know them.

Finally, we will have the chance to meet new Cocoa controls and we will learn how to override default appearance, such as changing the background color of a view; it might sound simple, but it’s not as straightforward as it is in iOS.

All the above will be presented by going through the steps of making a new simple application.

→ Keep Reading at AppCoda