把这些代码粘贴到你的ViewController就搞定啦
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIWindow * coverWindow =[[UIWindow alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 20)];
self.coverWindow = coverWindow;
coverWindow.hidden = YES;
coverWindow.backgroundColor = [UIColor whiteColor];
coverWindow.windowLevel = UIWindowLevelAlert;
//添加手势
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(coverWindowClick)];
[self.coverWindow addGestureRecognizer:tap];
});
- (void)coverWindowClick {
[UIView animateWithDuration:0.5 animations:^{
self.tableView.contentOffset = CGPointMake(0, 0);
}];
}
原文链接 http://www.jianshu.com/p/d48e9eba5e58
网友评论