1. 程式人生 > >自定義控制元件能實時檢視

自定義控制元件能實時檢視

自定義控制元件實時檢視

  • 建立一個xib檔案關聯某個view
  • 在view定義哪裡新增IB_DESIGNABLE
IB_DESIGNABLE
@interface xxView ()
@end
  • 圖片不顯示是由於bundel問題,寫個UIImage的分類
+ (UIImage *)imageWithNamed:(NSString *)name bundleForClass:(Class)cls {
    NSBundle *bundle;
#if TARGET_INTERFACE_BUILDER
    bundle = [NSBundle
bundleForClass:cls]; #else bundle = [NSBundle mainBundle]; #endif return [UIImage imageNamed:name inBundle:bundle compatibleWithTraitCollection:nil]; }