2

I've created a simple view that will show some AVPlayer content, or if this does not exist (initial state) draw a splash image.

I've added the IB_DESIGNABLE directive, and am drawing the splash image in drawRect. However, in Interface Builder, the component renders as a black square. I'd like it to draw the image. Is this possible?

At runtime all works fine.

4

2 回答 2

2

要调查 IB 再现中为您的drawRect:实现发生了什么,我建议使用调试器调试您的视图在 IB 中的行为方式。
为此,请在 IB 中选择您的视图,然后使用XCode 中菜单中的Debug Selected Views项目。Editor通过在 中设置断点,drawRect:您应该能够了解发生了什么以及为什么会出现黑色方块。

于 2015-02-08T20:13:45.023 回答
1

仅供参考,您可以使用关键字IBInspectablefe 在 IB 中设置自定义变量(例如您的图像):

IB_DESIGNABLE
@interface MyCustomControl : UIView
{
    IBInspectable UIImage *myImage;
    ...
}
...
@end

有关更多信息,请阅读这个很棒的博客,在那里我找到了那个关键字(我一直在寻找类似的东西)。

于 2015-02-26T15:20:20.263 回答