app-parate design / iOS Tip

Well, corporate design isn’t correct, so …

Under the many amazing things I encountered in exploring iOS the ridiculously easy-to-use appearance property is an enormous time-saver.

Say you have changed the properties of an iOS control and like how it looks now. Let there be 80 other instances of this type in your app that you want to look exactly the same. Change each individually in the inspector? Build a custom subclass and assign this to each?

Or simply (if you use declared properties – or maybe you can even extract the Xojo control class, haven’t tried yet):

declare function appearance lib UIKit selector "appearance" (id as ptr) as ptr return new AppleObject (appearance (classptr))

Or rather an override with the classtype in each declared control. Then, in a control’s or view’s open event something like

dim myAppear as AppleSwitch = AppleSwitch (AppleSwitch.Appearance) myAppear.TintColor = new applecolor (&cBAA4FF00) myAppear.ThumbTintColor = new applecolor (&c722CFF00) myAppear.OnTintColor =new applecolor ( &cDBB6FA00)

and the result looks like

Ok, in that case there’s a stretchable background image in the upper textfield and an iOS-driven tiled image in the background too. But I just did change “one” switch.

There’s another method to restrict the scope of the appearance change as well …