Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Sources/View/UICollectionViewLayout+Reusable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*********************************************
*
* This code is under the MIT License (MIT)
*
* Copyright (c) 2016 AliSoftware
*
*********************************************/

#if canImport(UIKit)
import UIKit

public extension UICollectionReusableView {
static var elementKind: String {
return String(describing: self)
}
}

public extension UICollectionViewLayout {
final func register<T: UICollectionReusableView>(decorationViewType: T.Type)
where T: Reusable & NibLoadable {
self.register(decorationViewType.nib, forDecorationViewOfKind: decorationViewType.elementKind)
}

final func register<T: UICollectionReusableView>(decorationViewType: T.Type)
where T: Reusable {
self.register(decorationViewType.self, forDecorationViewOfKind: decorationViewType.elementKind)
}
}

#endif