Adding @robdashnash quick response port
extension UITableView { func isFloatingSectionHeader( view:UITableViewHeaderFooterView )->Bool { if let section = section( for:view ) { return isFloatingHeaderInSection( section:section ) } return false } func isFloatingHeaderInSection( section:Int )->Bool { let frame = rectForHeader( inSection:section ) let y = contentInset.top + contentOffset.y return y > frame.origin.y } func section( for view:UITableViewHeaderFooterView )->Int? { for i in stride( from:0, to:numberOfSections, by:1 ) { let a = convert( CGPoint.zero, from:headerView( forSection:i ) ) let b = convert( CGPoint.zero, from:view ) if ay == by { return i } } return nil } }
source share