ios - 请教一个问题
阿神
阿神 2017-04-18 09:33:29
0
2
657

我想做一个这样的功能,把一些控件的属性设置放到一个单独的文件里,分开来,就像html和css那样,


这样写界面的时候就比较简单了


不用一大串一大串的设置属性。

现在的问题是,这个属性文件没有代码自动补全,比较麻烦,怎么样才能实现代码补全的功能?
还有个问题是对属性的解释有没有什么高效的办法?一个一个属性去解析然后设置,也比较麻烦
我用了kvc,但是kvc似乎不能解决所有问题

阿神
阿神

闭关修行中......

reply all(2)
刘奇
  1. There is no ready-made tool for code completion of files like yours. You can only write the Xcode plug-in yourself and put all the keywords and system method names in the SDK. Or use a text editor. Generally, text editors are more convenient to define your own syntax highlighting and code completion.

  2. There seems to be no easier way to explain attributes. However, you don’t need to define them one by one in advance. You can use respondsToSelectorperformSelector: NSSelectorFromString(set...)来设置属性值。对css里的属性名进行首字母大写然后前面加个 "set" 就是方法名了。
    class_copyMethodList to get all the methods of a certain class at runtime. Be careful to avoid crashes.

  3. It is better to use autolayout directly when writing css. Third-party autolayout can define constraints using code and configuration files, which is similar to css definition.

  4. Some people have done a lot of research on CSS layout before, you can study their code. For example https://github.com/gavinkwoe/... For example https://github.com/hackers-pa... For example https://github.com/tolo/Inter...
    Facebook also had a project before but abandoned that project a few years ago.

大家讲道理

If you create it like css, you can just create a bunch of base classes, or categories

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template