一、功能效果GIF圖:
二、實現代碼
-(void)arrowButtonTouched
{
//移動到最右側
CGFloat offsetW =self.scrollView.contentSize.width - [UIScreen mainScreen].bounds.size.width;
if(offsetW>0) {
ok_MainThread(^{
[self.scrollView setContentOffset:CGPointMake(offsetW,0) animated:YES];
});}}
//宏定義-封裝:
#define ok_MainThread(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_async(dispatch_get_main_queue(), block);\
}