I hereby claim:
- I am iranjith4 on github.
- I am iranjith4 (https://keybase.io/iranjith4) on keybase.
- I have a public key whose fingerprint is E5D7 9679 7498 084C 2F73 366F 976C 15E1 E68B FEF6
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
These template files will help you write documentation for library plugins.
If you wish to create a library plugin, you can code it in 2 ways:
UIFont.familyNames.sorted().forEach{ familyName in | |
print("*** \(familyName) ***") | |
UIFont.fontNames(forFamilyName: familyName).forEach { fontName in | |
print("\(fontName)") | |
} | |
print("---------------------") | |
} | |
/* | |
*** Academy Engraved LET *** |
///UITableView | |
myTableView.register(MyCustomTableViewCell.self, forCellReuseIdentifier: "MyCustomTableViewCell") | |
//HeaderFooterView | |
myTableView.register(UINib(nibName: String(describing: MyCustomTableViewHeaderFooterView.self), bundle: nil), forHeaderFooterViewReuseIdentifier: String(describing: MyCustomTableViewHeaderFooterView.self)) | |
//And you have used it like : | |
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | |
let header :MyCustomTableViewHeaderFooterView = tableView.dequeueReusableHeaderFooterView(withIdentifier: String(describing: MyCustomTableViewHeaderFooterView.self)) as! MyCustomTableViewHeaderFooterView | |
return header |
protocol ReusableView: class { | |
static var defaultReuseIdentifier: String { get } | |
} | |
protocol NibLoadableView: class { | |
static var nibName: String { get } | |
} |
extension ReusableView where Self: UIView { | |
static var defaultReuseIdentifier: String { | |
return String(describing: self) | |
} | |
} | |
extension NibLoadableView where Self: UIView { | |
static var nibName: String { | |
return String(describing: self) | |
} |
//CollectionView | |
extension UICollectionView { | |
func register<T: UICollectionViewCell>(_: T.Type) where T: ReusableView { | |
register(T.self, forCellWithReuseIdentifier: T.defaultReuseIdentifier) | |
} | |
func register<T: UICollectionViewCell>(_: T.Type) where T: ReusableView, T: NibLoadableView { | |
let bundle = Bundle(for: T.self) | |
let nib = UINib(nibName: T.nibName, bundle: bundle) |
//Dequeue methods for UICollectionView | |
func dequeueReusableCell<T: UICollectionViewCell>(for indexPath: IndexPath) -> T where T: ReusableView { | |
guard let cell = dequeueReusableCell(withReuseIdentifier: T.defaultReuseIdentifier, for: indexPath) as? T else { | |
fatalError("Could not dequeue cell with identifier: \(T.defaultReuseIdentifier)") | |
} | |
return cell | |
} | |
func dequeueReusableSupplementaryView<T: UICollectionReusableView>(ofKind: String, indexPath: IndexPath) -> T where T: ReusableView { |
/// UITableViewCell | |
class MyCustomTableViewCell: UITableViewCell, ReusableView, NibLoadableView { | |
} | |
// Or More suggested way | |
extension MyCustomTableViewCell: ReusableView, NibLoadableView { } | |
/// UITableViewHeaderFooterView | |
class MyCustomHeaderFooterView: UITableViewHeaderFooterView, ReusableView, NibLoadableView { | |
} |