UITableView的分类 滚动到底部 类似斗鱼点击查看底部消息


//
//  UITableView+scrollToBottom.h
//  yunxinDemo
//
//  Created by 刘小二 on 16/7/13.
//  Copyright © 2016年 刘小二. All rights reserved.
//  UITableView滚动到底部的方法

#import 

@interface UITableView (STScrollToBottom)

/**
 *  *  滚动到底部  类似QQ或者聊天室 滚动到底部 比如像斗鱼点击底部有消息
 *
 *  @param animated 是否有动画
 */
- (void)sTScrollToBottom:(BOOL)animated;

@end




//
//  UITableView+scrollToBottom.m
//  yunxinDemo
//
//  Created by 刘小二 on 16/7/13.
//  Copyright © 2016年 刘小二. All rights reserved.
//

#import "UITableView+STScrollToBottom.h"

@implementation UITableView (STScrollToBottom)

- (void)sTScrollToBottom:(BOOL)animated {

    if (self.contentSize.height + self.contentInset.top > self.frame.size.height) {
    
        [self setContentOffset:CGPointMake(0, self.contentSize.height  - self.frame.size.height) animated:animated];
    }
    
}

@end

你可能感兴趣的:(UITableView的分类 滚动到底部 类似斗鱼点击查看底部消息)