UIScrollView+QMUI.h
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*****
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*****/
//
// UIScrollView+QMUI.h
// qmui
//
// Created by QMUI Team on 15/7/20.
//
#import <UIKit/UIKit.h>
@interface UIScrollView (QMUI)
/// 判断UIScrollView是否已经处于顶部(当UIScrollView内容不够多不可滚动时,也认为是在顶部)
@property(nonatomic, assign, readonly) BOOL qmui_alreadyAtTop;
/// 判断UIScrollView是否已经处于底部(当UIScrollView内容不够多不可滚动时,也认为是在底部)
@property(nonatomic, assign, readonly) BOOL qmui_alreadyAtBottom;
/// UIScrollView 的真正 inset,在 iOS11 以后需要用到 adjustedContentInset 而在 iOS11 以前只需要用 contentInset
@property(nonatomic, assign, readonly) UIEdgeInsets qmui_contentInset;
/**
* 判断当前的scrollView内容是否足够滚动
* @warning 避免与<i>scrollEnabled</i>混淆
*/
- (BOOL)qmui_canScroll;
/**
* 不管当前scrollView是否可滚动,直接将其滚动到最顶部
* @param force 是否无视[self qmui_canScroll]而强制滚动
* @param animated 是否用动画表现
*/
- (void)qmui_scrollToTopForce:(BOOL)force animated:(BOOL)animated;
/**
* 等同于[self qmui_scrollToTopForce:NO animated:animated]
*/
- (void)qmui_scrollToTopAnimated:(BOOL)animated;
/// 等同于[self qmui_scrollToTopAnimated:NO]
- (void)qmui_scrollToTop;
/**
滚到列表顶部,但如果 contentInset.top 与上一次相同则不会执行滚动操作,通常用于 UIScrollViewContentInsetAdjustmentNever 的 scrollView 设置完业务的 contentInset 后将列表滚到顶部。特别地,对于 UITableView,建议使用 qmui_initialContentInset。
*/
- (void)qmui_scrollToTopUponContentInsetTopChange;
/**
* 如果当前的scrollView可滚动,则将其滚动到最底部
* @param animated 是否用动画表现
* @see [UIScrollView qmui_canScroll]
*/
- (void)qmui_scrollToBottomAnimated:(BOOL)animated;
/// 等同于[self qmui_scrollToBottomAnimated:NO]
- (void)qmui_scrollToBottom;
// 立即停止滚动,用于那种手指已经离开屏幕但列表还在滚动的情况。
- (void)qmui_stopDeceleratingIfNeeded;
@end