A cleaner code approach to NSLayout

On our previous screen, we built a very simple user interface using NSLayoutContraints.

Would you agree that the code looked quite clunky?

With our AudioPlayerPage, we are going to use a cleaner approach to coding the NSLayoutConstraints. Firstly, create a new folder called Extras, and add a new file called DictionaryViews.cs:

A cleaner code approach to NSLayout

This class is going to inherit the IEnumerable interface in order to create an NSDictionary; part of this interface is we must specify the GetEnumerator function. It will pull this from the NSDictionary; we also have our Add function, which simply adds a new UIView to the dictionary. Then we ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.