Last active
May 30, 2019 22:33
-
-
Save standinga/9f4bf93d62f43d98d543ab03cfefb15a to your computer and use it in GitHub Desktop.
CustomView for medium post about UICollectionView inside UIView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class CustomView: UIView { | |
@IBOutlet var contentView: UIView! | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
commonInit() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
commonInit() | |
} | |
private func commonInit() { | |
let bundle = Bundle(for: type(of: self)) | |
bundle.loadNibNamed("CustomView", owner: self, options: nil) | |
addSubview(contentView) | |
contentView.frame = bounds | |
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
contentView.backgroundColor = .red | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment