您的位置:首页 > 产品设计 > UI/UE

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上添加去除底色一句:
-(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];


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uiimageview uiimage 图片