首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

UITableView追随滑动的背景

2012-11-13 
UITableView跟随滑动的背景原帖地址: http://blog.csdn.net/favormm/article/details/7405857UITableView

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都可以 

热点排行