tableView自定义背景图结合masonry毛玻璃特效
2016-03-10 23:35
337 查看
完美主义者都喜欢自定义。tableView背景图虽然storyboard 没有更换backgroundView但可以用万能的代码实现自定义,
如果定义了backgroundView背景颜色,就不会显示自定义的背景图。
结合masonry冇玻璃特效和去除tableView 上的cell 底色发觉会眼前一亮;
为tableView .backgroundView添加自定义图片:
-(void)viewDidLoad{
[super viewDidLoad];
UIImageView * backImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
[backImageView setImage:[UIImage imageNamed:@"54541570_p0_master1200.jpg"]];
self.tableView.backgroundView = backImageView;
[self setupLoad];
继上面用masonry添加冇玻璃特效:
-(void)setupLoad{
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
[self.tableView.backgroundView addSubview:effectView];
[effectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
}];然后在tableView cell上添加去除底色一句:
如果定义了backgroundView背景颜色,就不会显示自定义的背景图。
结合masonry冇玻璃特效和去除tableView 上的cell 底色发觉会眼前一亮;
为tableView .backgroundView添加自定义图片:
-(void)viewDidLoad{
[super viewDidLoad];
UIImageView * backImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
[backImageView setImage:[UIImage imageNamed:@"54541570_p0_master1200.jpg"]];
self.tableView.backgroundView = backImageView;
[self setupLoad];
继上面用masonry添加冇玻璃特效:
-(void)setupLoad{
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
[self.tableView.backgroundView addSubview:effectView];
[effectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
}];然后在tableView cell上添加去除底色一句:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ ListingViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListingViewCell" forIndexPath:indexPath]; cell.backgroundColor = [UIColor clearColor]; MusicModel *mode = self.data[indexPath.row]; cell.data = mode; return cell;上面只是添加一句
cell.backgroundColor = [UIColor clearColor];
相关文章推荐
- 按右键另存图片只能存BMP
- photoshop去除图片上的水印
- upload上传单张图片
- 图片引发的溢出危机(图)
- C#实现把彩色图片灰度化代码分享
- C#将图片和字节流互相转换并显示到页面上
- C#监控文件夹并自动给图片文件打水印的方法
- 纯CSS实现的当鼠标移上图片添加阴影效果代码
- 如何使用C#从word文档中提取图片
- C#实现打开画图的同时载入图片、最大化显示画图窗体的方法
- C#图片添加水印的实现代码
- 随鼠标移动的图片或文字特效代码
- CSS 图片横向排列实现代码
- C#实现将Email地址转成图片显示的方法
- C#实现图片加相框的方法
- 超级经典一套鼠标控制左右滚动图片带自动翻滚
- 用css实现图片垂直居中的使用技巧
- C++实现读取图片长度和宽度
- Android实现图片异步加载并缓存到本地
- PHP根据图片色界在不同位置加水印的方法