diff --git a/Classes/NorthLayout.swift b/Classes/NorthLayout.swift
index 00013a7..426849e 100644
--- a/Classes/NorthLayout.swift
+++ b/Classes/NorthLayout.swift
@@ -37,3 +37,18 @@ public extension UXView {
}
}
}
+
+public class IBDesignableViewControllerView: UIView {
+ /// subclasses must override
+ public func prepareViewControllerForInterfaceBuilder() -> UIViewController { return UIViewController() }
+
+ override public func prepareForInterfaceBuilder() {
+ super.prepareForInterfaceBuilder()
+
+ let vc = prepareViewControllerForInterfaceBuilder()
+ let v = vc.view
+ v.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
+ v.frame = bounds
+ addSubview(v)
+ }
+}
diff --git a/Example/NorthLayout-ios/Playground.xib b/Example/NorthLayout-ios/Playground.xib
new file mode 100644
index 0000000..7c72c3d
--- /dev/null
+++ b/Example/NorthLayout-ios/Playground.xib
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Example/NorthLayout-ios/ViewController.swift b/Example/NorthLayout-ios/ViewController.swift
index 8163b67..a1d3321 100644
--- a/Example/NorthLayout-ios/ViewController.swift
+++ b/Example/NorthLayout-ios/ViewController.swift
@@ -20,14 +20,28 @@ private func colorImage(color: UIColor) -> UIImage {
}
+@IBDesignable
+class ViewControllerView: IBDesignableViewControllerView {
+ let vc = ViewController()
+ override func prepareViewControllerForInterfaceBuilder() -> UIViewController {
+ return vc
+ }
+
+ @IBInspectable var iconColor: UIColor? {
+ didSet { vc.iconView.image = iconColor.map{colorImage($0)} }
+ }
+}
+
class ViewController: UIViewController {
+
+ let iconView = UIImageView(image: colorImage(UIColor(red: 0.63, green: 0.9, blue: 1, alpha: 1)))
+
override func loadView() {
super.loadView()
edgesForExtendedLayout = .None
view.backgroundColor = UIColor.whiteColor()
- let iconView = UIImageView(image: colorImage(UIColor(red: 0.63, green: 0.9, blue: 1, alpha: 1)))
let iconWidth = CGFloat(32)
iconView.layer.cornerRadius = iconWidth / 2
iconView.clipsToBounds = true
@@ -39,6 +53,7 @@ class ViewController: UIViewController {
dateLabel.text = "1 min ago"
dateLabel.font = UIFont.systemFontOfSize(12)
dateLabel.textColor = UIColor.lightGrayColor()
+ dateLabel.setContentHuggingPriority(UILayoutPriorityDefaultHigh, forAxis: .Horizontal)
let textLabel = UILabel()
textLabel.text = "Some text go here"
diff --git a/Example/NorthLayout.xcodeproj/project.pbxproj b/Example/NorthLayout.xcodeproj/project.pbxproj
index f049869..18e8c23 100644
--- a/Example/NorthLayout.xcodeproj/project.pbxproj
+++ b/Example/NorthLayout.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
EA36301D1AFE29520015000C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EA36301C1AFE29520015000C /* Images.xcassets */; };
EA3630201AFE29520015000C /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = EA36301E1AFE29520015000C /* MainMenu.xib */; };
EA36302C1AFE29520015000C /* NorthLayout_osxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA36302B1AFE29520015000C /* NorthLayout_osxTests.swift */; };
+ EA9B5C461BCE72CD00CC2103 /* Playground.xib in Resources */ = {isa = PBXBuildFile; fileRef = EA9B5C451BCE72CD00CC2103 /* Playground.xib */; settings = {ASSET_TAGS = (); }; };
EAD9133E1AFE1FDE00F46CB9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD9133D1AFE1FDE00F46CB9 /* AppDelegate.swift */; };
EAD913401AFE1FDE00F46CB9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD9133F1AFE1FDE00F46CB9 /* ViewController.swift */; };
EAD913451AFE1FDE00F46CB9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAD913441AFE1FDE00F46CB9 /* Images.xcassets */; };
@@ -56,6 +57,7 @@
EA3630251AFE29520015000C /* NorthLayout-osx-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "NorthLayout-osx-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
EA36302A1AFE29520015000C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
EA36302B1AFE29520015000C /* NorthLayout_osxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NorthLayout_osxTests.swift; sourceTree = ""; };
+ EA9B5C451BCE72CD00CC2103 /* Playground.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Playground.xib; sourceTree = ""; };
EAD913381AFE1FDE00F46CB9 /* NorthLayout-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NorthLayout-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
EAD9133C1AFE1FDE00F46CB9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
EAD9133D1AFE1FDE00F46CB9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
@@ -190,6 +192,7 @@
children = (
EAD9133D1AFE1FDE00F46CB9 /* AppDelegate.swift */,
EAD9133F1AFE1FDE00F46CB9 /* ViewController.swift */,
+ EA9B5C451BCE72CD00CC2103 /* Playground.xib */,
EAD913441AFE1FDE00F46CB9 /* Images.xcassets */,
EAD913461AFE1FDE00F46CB9 /* LaunchScreen.xib */,
EAD9133B1AFE1FDE00F46CB9 /* Supporting Files */,
@@ -376,6 +379,7 @@
buildActionMask = 2147483647;
files = (
EAD913481AFE1FDE00F46CB9 /* LaunchScreen.xib in Resources */,
+ EA9B5C461BCE72CD00CC2103 /* Playground.xib in Resources */,
EAD913451AFE1FDE00F46CB9 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;