From 834c8c84be36304147ac8ece7444c73008eeaf03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarke=20Hesthaven=20S=C3=B8ndergaard?= Date: Thu, 17 Sep 2015 10:33:36 +0200 Subject: [PATCH 01/10] Update to Swift2 --- NibDesignable.swift | 20 +++++++++---------- .../project.pbxproj | 3 +++ .../Base.lproj/Main.storyboard | 5 +++-- .../Views/ProfileAvatarView.swift | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/NibDesignable.swift b/NibDesignable.swift index ee14602..6232530 100644 --- a/NibDesignable.swift +++ b/NibDesignable.swift @@ -30,7 +30,7 @@ extension UIView { /** Called to load the nib in setupNib(). - :returns: UIView instance loaded from a nib file. + - returns: UIView instance loaded from a nib file. */ public func loadNib() -> UIView { let bundle = NSBundle(forClass: self.dynamicType) @@ -41,7 +41,7 @@ extension UIView { /** Called in the default implementation of loadNib(). Default is class name. - :returns: Name of a single view nib file. + - returns: Name of a single view nib file. */ public func nibName() -> String { return self.dynamicType.description().componentsSeparatedByString(".").last! @@ -58,7 +58,7 @@ public class NibDesignable: UIView { } // MARK: - NSCoding - required public init(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.setupNib() } @@ -71,10 +71,10 @@ public class NibDesignable: UIView { private func setupNib() { let view = self.loadNib() self.addSubview(view) - view.setTranslatesAutoresizingMaskIntoConstraints(false) + view.translatesAutoresizingMaskIntoConstraints = false let bindings = ["view": view] - self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(0), metrics:nil, views: bindings)) - self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(0), metrics:nil, views: bindings)) + self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) } } @@ -88,7 +88,7 @@ public class NibDesignableTableViewCell: UITableViewCell { } // MARK: - NSCoding - required public init(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.setupNib() } @@ -101,9 +101,9 @@ public class NibDesignableTableViewCell: UITableViewCell { private func setupNib() { let view = self.loadNib() self.contentView.addSubview(view) - view.setTranslatesAutoresizingMaskIntoConstraints(false) + view.translatesAutoresizingMaskIntoConstraints = false let bindings = ["view": view] - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(0), metrics:nil, views: bindings)) - self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(0), metrics:nil, views: bindings)) + self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) } } diff --git a/NibDesignableDemo/NibDesignableDemo.xcodeproj/project.pbxproj b/NibDesignableDemo/NibDesignableDemo.xcodeproj/project.pbxproj index aba747a..cc9e960 100644 --- a/NibDesignableDemo/NibDesignableDemo.xcodeproj/project.pbxproj +++ b/NibDesignableDemo/NibDesignableDemo.xcodeproj/project.pbxproj @@ -184,6 +184,8 @@ 5AD66C33198C06A70006A638 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0600; ORGANIZATIONNAME = "Morten Bøgh"; TargetAttributes = { @@ -446,6 +448,7 @@ 5AD7CA421A6152F5002E66A8 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/NibDesignableDemo/NibDesignableDemo/Base.lproj/Main.storyboard b/NibDesignableDemo/NibDesignableDemo/Base.lproj/Main.storyboard index f527765..b84b5e9 100644 --- a/NibDesignableDemo/NibDesignableDemo/Base.lproj/Main.storyboard +++ b/NibDesignableDemo/NibDesignableDemo/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + - + + diff --git a/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift b/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift index e0f7bbf..9930d04 100644 --- a/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift +++ b/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift @@ -39,7 +39,7 @@ public class ProfileAvatarView: NibDesignable { let size = self.profileImage.size let rect = CGRectMake(0, 0, size.width, size.height) UIGraphicsBeginImageContextWithOptions(size, false, 0.0) - var path = UIBezierPath(ovalInRect: rect) + let path = UIBezierPath(ovalInRect: rect) path.addClip() self.profileImage.drawInRect(rect) @@ -51,7 +51,7 @@ public class ProfileAvatarView: NibDesignable { // MARK: Interface Builder override public func prepareForInterfaceBuilder() { - if count(self.name) == 0 { + if self.name.characters.count == 0 { self.name = "John Appleseed" } From d12f7cb4b2ab9f33eca88daecfecc7edadc82eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarke=20Hesthaven=20S=C3=B8ndergaard?= Date: Thu, 17 Sep 2015 10:40:46 +0200 Subject: [PATCH 02/10] Update travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39ab909..dd694b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -osx_image: beta-xcode6.3 +osx_image: xcode7 language: objective-c script: - xctool -project NibDesignableDemo/NibDesignableDemo.xcodeproj -scheme NibDesignableDemo -sdk iphonesimulator From 462265a37b510b782da6f8bde80a2198825820be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarke=20Hesthaven=20S=C3=B8ndergaard?= Date: Thu, 17 Sep 2015 10:50:46 +0200 Subject: [PATCH 03/10] Removed iOS9 only API and updated travis --- .travis.yml | 3 +++ .../NibDesignableDemo/Views/ProfileAvatarView.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd694b5..ef781a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,6 @@ language: objective-c script: - xctool -project NibDesignableDemo/NibDesignableDemo.xcodeproj -scheme NibDesignableDemo -sdk iphonesimulator - xctool -project NibDesignableDemo/NibDesignableDemo.xcodeproj test -scheme NibDesignableDemo -sdk iphonesimulator +before_install: + - brew update + - brew uninstall xctool && brew install --HEAD xctool diff --git a/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift b/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift index 9930d04..9da2b39 100644 --- a/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift +++ b/NibDesignableDemo/NibDesignableDemo/Views/ProfileAvatarView.swift @@ -51,7 +51,7 @@ public class ProfileAvatarView: NibDesignable { // MARK: Interface Builder override public func prepareForInterfaceBuilder() { - if self.name.characters.count == 0 { + if self.name.utf8.count == 0 { self.name = "John Appleseed" } From 6e1b63be9398056a677b741356257dd4a6dca2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20B=C3=B8gh?= Date: Thu, 17 Sep 2015 11:00:14 +0200 Subject: [PATCH 04/10] Version 2.0.0 release dance --- .gitignore | 3 ++- NibDesignable.podspec | 2 +- README.md | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index da384aa..4f9d49f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ xcuserdata -*.xccheckout \ No newline at end of file +*.xccheckout +.DS_Store diff --git a/NibDesignable.podspec b/NibDesignable.podspec index 6aefef2..7588504 100644 --- a/NibDesignable.podspec +++ b/NibDesignable.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NibDesignable' - s.version = '1.1.1' + s.version = '2.0.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'Elegant way of enabling IBDesignable on your nib-based views' s.homepage = 'https://github.com/mbogh/NibDesignable' diff --git a/README.md b/README.md index d3db800..a26c91d 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ Nib Designable is released under an MIT license. See LICENSE for more informatio ## Release Notes +Version 2.0.0 + +- Swift 2.0 for everyone, thanks to @bjarkehs + Version 1.1.1 - Fixed minor issue with `UITableViewCell` From 272e18ba1daaddc80d1d1e15d29d18dc65f58c5f Mon Sep 17 00:00:00 2001 From: Sebastian Stallenberger Date: Thu, 17 Sep 2015 11:57:09 +0200 Subject: [PATCH 05/10] Add support for UIControl --- NibDesignable.swift | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/NibDesignable.swift b/NibDesignable.swift index 6232530..495bb8e 100644 --- a/NibDesignable.swift +++ b/NibDesignable.swift @@ -107,3 +107,33 @@ public class NibDesignableTableViewCell: UITableViewCell { self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) } } + +@IBDesignable +public class NibDesignableControl: UIControl { + + // MARK: - Initializer + override public init(frame: CGRect) { + super.init(frame: frame) + self.setupNib() + } + + // MARK: - NSCoding + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + self.setupNib() + } + + // MARK: - Nib loading + + /** + Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview. + */ + private func setupNib() { + let view = self.loadNib() + self.addSubview(view) + view.translatesAutoresizingMaskIntoConstraints = false + let bindings = ["view": view] + self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + } +} From 0d0235e696275187320c7387bfecd0c6cb45c807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20B=C3=B8gh?= Date: Thu, 17 Sep 2015 19:33:51 +0200 Subject: [PATCH 06/10] Version 2.1.0 --- NibDesignable.podspec | 2 +- README.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NibDesignable.podspec b/NibDesignable.podspec index 7588504..e35a96a 100644 --- a/NibDesignable.podspec +++ b/NibDesignable.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NibDesignable' - s.version = '2.0.0' + s.version = '2.1.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'Elegant way of enabling IBDesignable on your nib-based views' s.homepage = 'https://github.com/mbogh/NibDesignable' diff --git a/README.md b/README.md index a26c91d..fd8caed 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ Nib Designable is released under an MIT license. See LICENSE for more informatio ## Release Notes +Version 2.1.0 + +- `UIControl` support added by @illaz + Version 2.0.0 - Swift 2.0 for everyone, thanks to @bjarkehs From f532ba145ab90a8be85e040c8b4fcda9fd44ba0a Mon Sep 17 00:00:00 2001 From: Andrey Pyankov Date: Fri, 18 Sep 2015 10:32:15 +0700 Subject: [PATCH 07/10] Add support for UICollectionViewCell --- NibDesignable.swift | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/NibDesignable.swift b/NibDesignable.swift index 495bb8e..7af6745 100644 --- a/NibDesignable.swift +++ b/NibDesignable.swift @@ -137,3 +137,33 @@ public class NibDesignableControl: UIControl { self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) } } + +@IBDesignable +public class NibDesignableCollectionViewCell: UICollectionViewCell { + + // MARK: - Initializer + override init(frame: CGRect) { + super.init(frame: frame) + self.setupNib() + } + + // MARK: - NSCoding + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + self.setupNib() + } + + // MARK: - Nib loading + + /** + Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview. + */ + private func setupNib() { + let view = self.loadNib() + self.contentView.addSubview(view) + view.translatesAutoresizingMaskIntoConstraints = false + let bindings = ["view": view] + self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) + } +} From 083d267c304be151492f1f3f196fdf26babc23f2 Mon Sep 17 00:00:00 2001 From: Andrey Pyankov Date: Fri, 18 Sep 2015 23:12:39 +0700 Subject: [PATCH 08/10] fix public init in UICollectionViewCell --- NibDesignable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NibDesignable.swift b/NibDesignable.swift index 7af6745..adfff95 100644 --- a/NibDesignable.swift +++ b/NibDesignable.swift @@ -142,7 +142,7 @@ public class NibDesignableControl: UIControl { public class NibDesignableCollectionViewCell: UICollectionViewCell { // MARK: - Initializer - override init(frame: CGRect) { + override public init(frame: CGRect) { super.init(frame: frame) self.setupNib() } From 1639a153381464475dce3683fa57e2020f753a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20B=C3=B8gh?= Date: Mon, 21 Sep 2015 21:35:30 +0200 Subject: [PATCH 09/10] Version 2.2.0 --- NibDesignable.podspec | 2 +- README.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NibDesignable.podspec b/NibDesignable.podspec index e35a96a..333944c 100644 --- a/NibDesignable.podspec +++ b/NibDesignable.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NibDesignable' - s.version = '2.1.0' + s.version = '2.2.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'Elegant way of enabling IBDesignable on your nib-based views' s.homepage = 'https://github.com/mbogh/NibDesignable' diff --git a/README.md b/README.md index fd8caed..363ef9a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ Nib Designable is released under an MIT license. See LICENSE for more informatio Version 2.1.0 +- `UICollectionViewCell` support added by @pyankoff + +Version 2.1.0 + - `UIControl` support added by @illaz Version 2.0.0 From e9ee6784a3f81c135a9a4b856cb73ab38ac8e60d Mon Sep 17 00:00:00 2001 From: Syo Ikeda Date: Thu, 24 Sep 2015 17:28:56 +0900 Subject: [PATCH 10/10] Fix release notes in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 363ef9a..c862165 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Nib Designable is released under an MIT license. See LICENSE for more informatio ## Release Notes -Version 2.1.0 +Version 2.2.0 - `UICollectionViewCell` support added by @pyankoff