Is there a CSS equivalent for XIB (Xcode Interface Builder XML)?

Can I use XIB style files created by Xcode? Something equivalent to styling an HTML file using CSS? I would like to be able to, say, change the background image for all buttons or for all buttons of a certain class.

(I understand that I could probably use XSLT to convert a XIB file or subclass of NSButton to set the default background, but I would rather use a style sheet type mechanism if one exists)

Thanks, James

+6
source share
2 answers

I am also looking for something like that. I found this closest I could find:

Checked :

The ability to add additional personalization features to the interface, such as round corners, border width, border color ... https://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6 /

Subsequently, I created this for buttons as an example:

@IBDesignable public class DesignableButton: UIButton { @IBInspectable var buttonStyle: String { set { switch newValue { case "green": layer.frame.size.height = 44 layer.cornerRadius = 22 layer.backgroundColor = UIColor.greenColor().CGColor case "white": layer.backgroundColor = UIColor.whiteColor().CGColor layer.frame.size.height = 44 layer.cornerRadius = 22 default: break } } } } 

Swift UI :

I haven’t tried it, but it seems like a great solution, you can style your application with CSS: https://github.com/tombenner/nui

0
source

As far as I know, such a mechanism does not exist. It depends on your needs, but what you could do is use WebView for your application user interface; this will allow you to fully customize the CSS.

An example can be found on Matt Gemmel's blog . CocUI may also be of interest.

-1
source

Source: https://habr.com/ru/post/903795/


All Articles