Custom Viewをxibファイルで作りたい時があると思います。そして、それをオブジェクト化する方法はいくつかあります。 Custom Viewクラスの初期化処理で、xibのViewをオブジェクト化して、それをaddSubviewする 自分はこれが最適解かなと思っています。理由は、 storyboard、xibでも、そのCustom Viewを使えるようになること initWithFrameなどプログラムから生成したい場合も対応可能 になることです。 手短に手順を説明すると以下のようになります。 xibファイルを作る xib上のViewにSubviewを配置する Custom Viewとなるクラスを作る xibのFile’s OwnerのCustom ClassをCustom Viewのクラス名にする CustomViewのinitWithCoder、initWithFrameで、xi
![Custom Viewをxibで作る方法を考察 | Cyber Passion for iOS](https://cdn-ak-scissors.b.st-hatena.com/image/square/02552bde15f1ebb0decca19552fb781232f990f4/height=288;version=1;width=512/http%3A%2F%2Fblogios.stack3.net%2Fwp-content%2Fuploads%2F2015%2F04%2Fcyberpassion-logo-ogp.png)