DateLabelCustom.swift 936 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import UIKit
  6. @objcMembers public class DateLabelCustom: UILabel {
  7. weak var tableView: UITableView?
  8. func labelTapped(recognizer: UIGestureRecognizer) {
  9. let locationOfTouch = recognizer.location(in: self.tableView)
  10. if let location = self.tableView!.indexPathForRow(at: locationOfTouch) {
  11. DispatchQueue.main.async {
  12. self.tableView?.scrollToRow(at: IndexPath(row: 0, section: location.section), at: .none, animated: true)
  13. self.tableView?.layoutSubviews()
  14. }
  15. }
  16. }
  17. required init?(coder: NSCoder) {
  18. super.init(coder: coder)
  19. let gesture = UITapGestureRecognizer(target: self, action: #selector(labelTapped))
  20. self.addGestureRecognizer(gesture)
  21. self.isUserInteractionEnabled = true
  22. }
  23. }