UITableView跟随滑动的背景
原帖地址: http://blog.csdn.net/favormm/article/details/7405857
UITableView的backgroundView属性可以设置其背景,但是背景不能随Table的拖动而移动,也就是固定不移动的。
想办法让其背景也随拖动而移动
两步
1. set the background of UITableView to clear color
CALayer *bgLayer = [CALayer layer]; bgLayer.contents = (id)[UIImage imageNamed:@"setting-main-bg"].CGImage; bgLayer.anchorPoint = CGPointZero; bgLayer.bounds = CGRectMake(0, 0, self.scrollBgTableView.contentSize.width , self.scrollBgTableView.contentSize.height + 50); CGRect rect = bgLayer.frame; rect.origin.y = -50; bgLayer.frame = rect; [self.scrollBgTableView.layer addSublayer:bgLayer]; bgLayer.zPosition = -5; //这一句一定要,数值得小于0都可以