diff --git a/.swift-version b/.swift-version index 9f55b2c..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/NibDesignable.podspec b/NibDesignable.podspec index 384d5ff..986cd58 100644 --- a/NibDesignable.podspec +++ b/NibDesignable.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'NibDesignable' - s.version = '3.0.0' + s.version = '4.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/NibDesignable.swift b/NibDesignable.swift index 756e617..a537861 100644 --- a/NibDesignable.swift +++ b/NibDesignable.swift @@ -27,21 +27,21 @@ public protocol NibDesignableProtocol: NSObjectProtocol { /** Identifies the view that will be the superview of the contents loaded from the Nib. Referenced in setupNib(). - + - returns: Superview for Nib contents. */ var nibContainerView: UIView { get } // MARK: - Nib loading - + /** Called to load the nib in setupNib(). - + - returns: UIView instance loaded from a nib file. */ func loadNib() -> UIView /** Called in the default implementation of loadNib(). Default is class name. - + - returns: Name of a single view nib file. */ func nibName() -> String @@ -49,10 +49,10 @@ public protocol NibDesignableProtocol: NSObjectProtocol { extension NibDesignableProtocol { // MARK: - Nib loading - + /** Called to load the nib in setupNib(). - + - returns: UIView instance loaded from a nib file. */ public func loadNib() -> UIView { @@ -60,9 +60,9 @@ extension NibDesignableProtocol { let nib = UINib(nibName: self.nibName(), bundle: bundle) return nib.instantiate(withOwner: self, options: nil)[0] as! UIView // swiftlint:disable:this force_cast } - + // MARK: - Nib loading - + /** Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview. */ @@ -77,12 +77,9 @@ extension NibDesignableProtocol { } extension UIView { - public var nibContainerView: UIView { - return self - } /** Called in the default implementation of loadNib(). Default is class name. - + - returns: Name of a single view nib file. */ open func nibName() -> String { @@ -92,13 +89,16 @@ extension UIView { @IBDesignable open class NibDesignable: UIView, NibDesignableProtocol { + public var nibContainerView: UIView { + return self + } // 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) @@ -108,16 +108,16 @@ open class NibDesignable: UIView, NibDesignableProtocol { @IBDesignable open class NibDesignableTableViewCell: UITableViewCell, NibDesignableProtocol { - public override var nibContainerView: UIView { + public var nibContainerView: UIView { return self.contentView } - + // MARK: - Initializer override public init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) self.setupNib() } - + // MARK: - NSCoding required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) @@ -127,33 +127,36 @@ open class NibDesignableTableViewCell: UITableViewCell, NibDesignableProtocol { @IBDesignable open class NibDesignableTableViewHeaderFooterView: UITableViewHeaderFooterView, NibDesignableProtocol { - - public override var nibContainerView: UIView { - return self.contentView - } - - // MARK: - Initializer - override public init(reuseIdentifier: String?) { - super.init(reuseIdentifier: reuseIdentifier) - self.setupNib() - } - - // MARK: - NSCoding - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - self.setupNib() - } + + public var nibContainerView: UIView { + return self.contentView + } + + // MARK: - Initializer + override public init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) + self.setupNib() + } + + // MARK: - NSCoding + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + self.setupNib() + } } @IBDesignable open class NibDesignableControl: UIControl, NibDesignableProtocol { + public var nibContainerView: UIView { + return self + } // 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) @@ -163,13 +166,16 @@ open class NibDesignableControl: UIControl, NibDesignableProtocol { @IBDesignable open class NibDesignableCollectionReusableView: UICollectionReusableView, NibDesignableProtocol { + public var nibContainerView: UIView { + return self + } // 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) @@ -179,19 +185,20 @@ open class NibDesignableCollectionReusableView: UICollectionReusableView, NibDes @IBDesignable open class NibDesignableCollectionViewCell: UICollectionViewCell, NibDesignableProtocol { - public override var nibContainerView: UIView { + public var nibContainerView: UIView { return self.contentView } - + // 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() } } +