123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // XYChatRoomScrollCollectionViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/6/28.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYChatRoomScrollCollectionViewController.h"
- @interface XYChatRoomScrollCollectionViewController ()
- @property (nonatomic,assign) CGFloat lastOffset;
- @end
- @implementation XYChatRoomScrollCollectionViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (void)setIsCloseScrollSwitch:(BOOL)isCloseScrollSwitch {
- _isCloseScrollSwitch = isCloseScrollSwitch;
- if (isCloseScrollSwitch) {
- self.canScroll = YES;
- }
- }
- - (void)setCanScroll:(BOOL)canScroll {
- _canScroll = canScroll;
- self.lastOffset = self.collectionView.contentOffset.y;
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- // NSLog(@"collectionView >>>>>>> 滚动 == %.2F",scrollView.contentOffset.y);
- if (self.isCloseScrollSwitch) {
- return;
- }
- if (!self.canScroll) {
- scrollView.contentOffset = CGPointZero;
- }
- if (scrollView.contentOffset.y < 0 ) {
- self.canScroll = NO;
- scrollView.contentOffset = CGPointZero;
- [[NSNotificationCenter defaultCenter] postNotificationName:@"chatroom_controller_leave_top" object:nil];//到顶通知父视图改变状态
- }
- scrollView.showsVerticalScrollIndicator = self.canScroll?YES:NO;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|