Ryusuke Fuda's Tech Blog

Softweare Enginier about Web, iOS, Android.

iOS TableViewのCellの背景をぼかす

■ 今はやりのやつ。

    UIImage *logoImg = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]];
    UIImageView *logoImgView = [[UIImageView alloc] initWithImage:logoImg];
    
    //Making bokashi
    logoImgView.layer.shouldRasterize = YES;
    logoImgView.layer.rasterizationScale = 0.1;
    logoImgView.layer.minificationFilter = kCAFilterTrilinear;
    
    cell.backgroundView = logoImgView;

UIImageではなくUIImageViewをcell.backgroundViewにいれる。
ぼかしはわずか3行でできる。

参考)
http://objc-lovers.com/archives/111
http://runlooprun.wordpress.com/2010/12/02/cell_with_custom_bg/