能不能像css那样对多个相似的组合统一处理。。 包括字体大小啊,样式啊
不知道ios里面可有方便的方法处理这种场景?
P.S:
好比css里能为一组元素设置一个class,然后给这种标识为该class的元素指定字体大小,颜色, 而ios里是怎么做到的?
PHP中文网2017-04-17 11:44:37
Inherit. . . Inherit UILabel and set the format in the initialization method
PHP中文网2017-04-17 11:44:37
You can use factory methods to set the same properties when creating. For different style classes, create different factory classes or modify methods.
In addition, I have written a CSS-like viewCreater, which can be customized and set. If you are interested, you can take a look.
// style.css UIView{background-color:black;width:240px; height:32px;} .testStyle{border-width:1px;border-color:white;border-radius:5px;}
// demo.m UIView *widget = [UIView viewWithSelector:@".testStyle"];
You will get a view with a black background, 240 pixels wide, 32 pixels high, and a 1 pixel wide rounded corner.
https://github.com/rarexray/iOS_ViewCreatorWithStyle