X-Git-Url: https://git.mdrn.pl/wl-app.git/blobdiff_plain/53b27422d140022594fc241cca91c3183be57bca..48b2fe9f7c2dc3d9aeaaa6dbfb27c7da4f3235ff:/iOS/WolneLektury/Screens/Common/Views/DesignableXibView.swift?ds=sidebyside diff --git a/iOS/WolneLektury/Screens/Common/Views/DesignableXibView.swift b/iOS/WolneLektury/Screens/Common/Views/DesignableXibView.swift new file mode 100644 index 0000000..e1e1091 --- /dev/null +++ b/iOS/WolneLektury/Screens/Common/Views/DesignableXibView.swift @@ -0,0 +1,39 @@ +// +// DesignableXibView.swift +// WolneLektury +// +// Created by Pawel Dabrowski on 18/06/2018. +// Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved. +// + +import UIKit + +class DesignableXibView: UIView { + + var contentView : UIView! + + override init(frame: CGRect) { + super.init(frame: frame) + xibSetup() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + xibSetup() + } + + func xibSetup() { + contentView = loadViewFromNib() + contentView.frame = bounds + contentView.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight] + addSubview(contentView) + } + + func loadViewFromNib() -> UIView! { + let bundle = Bundle(for: type(of: self)) + let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle) + let view = nib.instantiate(withOwner: self, options: nil).first as! UIView + + return view + } +}