Skip to content

Commit

Permalink
Adds stickyRow/Column-Header options
Browse files Browse the repository at this point in the history
If set to `true` the header always stays at the top. Even if the user bounces.
  • Loading branch information
leoMehlig committed Jul 6, 2017
1 parent 99f8848 commit 1deabea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Framework/Sources/SpreadsheetView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ extension SpreadsheetView {
layoutRowHeader()
layoutColumnHeader()

if self.stickyRowHeader {
self.rowHeaderView.frame.origin.y = min(self.rootView.contentOffset.y, 0)
self.rowHeaderView.contentOffset.x = self.tableView.contentOffset.x
self.cornerView.frame.origin.y = min(self.rootView.contentOffset.y, 0)
}
if self.stickyColumnHeader {
self.columnHeaderView.frame.origin.x = min(self.rootView.contentOffset.x, 0)
self.columnHeaderView.contentOffset.y = self.tableView.contentOffset.y
self.cornerView.frame.origin.x = min(self.rootView.contentOffset.x, 0)
}

if needsReload {
adjustScrollViewFrames()

Expand Down
14 changes: 14 additions & 0 deletions Framework/Sources/SpreadsheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ public class SpreadsheetView: UIView {
tableView.alwaysBounceHorizontal = newValue
}
}

/// A Boolean value that determines wheather the row header always sticks to the top.
/// - Note: `bounces` has to be `true` and there has to be at least one `frozenRow`.
/// The default value is `false`.
///
/// - SeeAlso: `stickyColumnHeader`
public var stickyRowHeader: Bool = false

/// A Boolean value that determines wheather the column header always sticks to the top.
/// - Note: `bounces` has to be `true` and there has to be at least one `frozenColumn`.
/// The default value is `false`.
///
/// - SeeAlso: `stickyRowHeader`
public var stickyColumnHeader: Bool = false

/// A Boolean value that determines whether paging is enabled for the scroll view.
/// - Note: If the value of this property is `true`, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls.
Expand Down

0 comments on commit 1deabea

Please sign in to comment.