单军华
2018-07-19 83b9d5c682b21d88133f24da0f94dd56bd79e687
screendisplay/Pods/YYCategories/YYCategories/UIKit/UIScrollView+YYAdd.m
New file
@@ -0,0 +1,60 @@
//
//  UIScrollView+YYAdd.m
//  YYCategories <https://github.com/ibireme/YYCategories>
//
//  Created by ibireme on 13/4/5.
//  Copyright (c) 2015 ibireme.
//
//  This source code is licensed under the MIT-style license found in the
//  LICENSE file in the root directory of this source tree.
//
#import "UIScrollView+YYAdd.h"
#import "YYCategoriesMacro.h"
YYSYNTH_DUMMY_CLASS(UIScrollView_YYAdd)
@implementation UIScrollView (YYAdd)
- (void)scrollToTop {
    [self scrollToTopAnimated:YES];
}
- (void)scrollToBottom {
    [self scrollToBottomAnimated:YES];
}
- (void)scrollToLeft {
    [self scrollToLeftAnimated:YES];
}
- (void)scrollToRight {
    [self scrollToRightAnimated:YES];
}
- (void)scrollToTopAnimated:(BOOL)animated {
    CGPoint off = self.contentOffset;
    off.y = 0 - self.contentInset.top;
    [self setContentOffset:off animated:animated];
}
- (void)scrollToBottomAnimated:(BOOL)animated {
    CGPoint off = self.contentOffset;
    off.y = self.contentSize.height - self.bounds.size.height + self.contentInset.bottom;
    [self setContentOffset:off animated:animated];
}
- (void)scrollToLeftAnimated:(BOOL)animated {
    CGPoint off = self.contentOffset;
    off.x = 0 - self.contentInset.left;
    [self setContentOffset:off animated:animated];
}
- (void)scrollToRightAnimated:(BOOL)animated {
    CGPoint off = self.contentOffset;
    off.x = self.contentSize.width - self.bounds.size.width + self.contentInset.right;
    [self setContentOffset:off animated:animated];
}
@end