Design UIView subclass auto layout with custom size in Interface Builder xib file

冷暖自知 提交于 2019-12-24 08:09:03

问题


I have an UIView subclass with its layout in a .xib file. I set the size to freeform and the dimensions to something like 200 x 300.

How can I set different dimensions for iPad so the "View as" option correctly show a preview of how it would look like?

Or, can this be achieved in a different way? Maybe using a storyboard instead of a xib file?


回答1:


Similar kind of feature I did last week. I had an xib file and that I was using as a collectionView item. Through interface builder it cannot be differed. I achieved this programmatically. You can change the size of UIView as required.

Let me know if you have any query.




回答2:


Certainly, you can make it compatible with Auto Layout and you can use IBDesignable to do visual layout in Interface Builder.

I have a couple examples - including loading custom views from XIB files - here: https://github.com/DonMag/IBDesignInspect



来源:https://stackoverflow.com/questions/42860812/design-uiview-subclass-auto-layout-with-custom-size-in-interface-builder-xib-fil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!