Skip to content

Instantly share code, notes, and snippets.

@standinga
Last active May 30, 2019 22:33
Show Gist options
  • Save standinga/9f4bf93d62f43d98d543ab03cfefb15a to your computer and use it in GitHub Desktop.
Save standinga/9f4bf93d62f43d98d543ab03cfefb15a to your computer and use it in GitHub Desktop.
CustomView for medium post about UICollectionView inside UIView
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