Last active
March 12, 2020 04:14
-
-
Save rsaenzi/e2ab2c4e78ee7ba12c9b534ec4982530 to your computer and use it in GitHub Desktop.
Template for custom table cell loaded from a .xib file
This file contains 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
// | |
// CustomCell.swift | |
// | |
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/) | |
// Copyright © 2019. All rights reserved. | |
// | |
// Notes: | |
// - Bind content to the ContentView in Interface Builder | |
// - Make the xib's file owner be this class | |
import UIKit | |
class TableCell: UITableViewCell { | |
// This property must be bound to the ContentView view in Xcode Interface Builder | |
@IBOutlet private weak var content: UIView! | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
sharedInit() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
sharedInit() | |
} | |
private func sharedInit() { | |
loadNib() | |
addSubview(content) | |
// Expand to fill its parent | |
content.frame = self.bounds | |
content.autoresizingMask = [.flexibleHeight, .flexibleWidth] | |
} | |
} |
CustomView.swift
https://gist.github.com/rsaenzi/1f5b02729ad42e6ca063e9db7d84408d
UITableView+Load.swift
https://gist.github.com/rsaenzi/9df6cb80fe4828d89aa664de03b5f25f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UIView+Load.swift
https://gist.github.com/rsaenzi/0c3da9a1f5084c6ac73cee0b501daf33