2021-02-07 07:42:50 +01:00
|
|
|
//
|
|
|
|
// ScrollViewContainer.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by sxiaojian on 2021/2/7.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
protocol ScrollViewContainer: UIViewController {
|
2022-05-13 11:23:35 +02:00
|
|
|
var scrollView: UIScrollView { get }
|
2021-02-07 07:42:50 +01:00
|
|
|
func scrollToTop(animated: Bool)
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ScrollViewContainer {
|
|
|
|
func scrollToTop(animated: Bool) {
|
2022-11-03 14:24:30 +01:00
|
|
|
scrollView.scrollToTop(animated: animated)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension UIScrollView {
|
|
|
|
func scrollToTop(animated: Bool) {
|
|
|
|
scrollRectToVisible(CGRect(origin: .zero, size: CGSize(width: 1, height: 1)), animated: animated)
|
2021-02-07 07:42:50 +01:00
|
|
|
}
|
|
|
|
}
|