Search code examples
objective-cioscalayeruicollectionview

applying shadow for the view makes my text blurry


My collection view cell structure is described as below

enter image description here

For cellItemAtIndex, I do the following

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell    *cell   =   [self.collectionView dequeueReusableCellWithReuseIdentifier:@"reusedCell" forIndexPath:indexPath];


    // Set shadow around the cell
    [cell.layer setMasksToBounds    :NO ];
    [cell.layer setShadowColor      :[[UIColor whiteColor ] CGColor ] ];// shadow's color
    [cell.layer setShadowOpacity    :0.65 ];                            // set the opacty
    [cell.layer setShadowRadius     :5.0 ];                             // set the blur radius
    [cell.layer setShadowOffset     :CGSizeMake( 0 , 0 ) ];             // set shadow position
    [cell.layer setShouldRasterize  :YES ];                             // tell the cell to render it’s CALayer as a bitmap
    [cell.layer setShadowPath       :[[UIBezierPath bezierPathWithRect:cell.bounds ] CGPath ] ];    // use a path to draw its shadow instead of using its
    ......................................................................
}

When I run the application on the device, the shadow is shown. However, my text for the labels are blurry. Please take a look at following imaged taken from my device

enter image description here

If I uncomment the bode block which is used to drop the shadow, the text are so clear as the following image enter image description here

I am....totally lost. Does anybody have any ideas about this issue. Please help


Solution

  • I would remove setShouldRasterize, setShadowOffset and setShadowPath. It will work without them just fine.