mastodon-ios/Mastodon/Protocol/ScrollViewContainer.swift

26 lines
544 B
Swift
Raw Normal View History

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) {
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
}
}