tableView自定义背景图结合masonry毛玻璃特效

来源:互联网 发布:德旭交规软件 编辑:程序博客网 时间:2024/05/14 12:33

完美主义者都喜欢自定义。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上添加去除底色一句:
-(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];



0 0
原创粉丝点击