6

我的收藏视图单元格结构描述如下

在此处输入图像描述

对于cellItemAtIndex,我执行以下操作

- (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
    ......................................................................
}

当我在设备上运行应用程序时,会显示阴影。但是,我的标签文字很模糊。请查看以下从我的设备拍摄的图像

在此处输入图像描述

如果我取消注释用于放置阴影的 bode 块,则文本非常清晰,如下图所示 在此处输入图像描述

我……完全迷路了。有没有人对这个问题有任何想法。请帮忙

4

2 回答 2

8

您正在栅格化图层,但默认栅格化比例为 1.0。对于视网膜显示器,需要将其设置为 2.0,否则该图层仅以一半分辨率呈现。

cell.layer.rasterizationScale=[[UIScreen mainScreen] scale];
于 2012-12-31T11:00:13.563 回答
3

我会删除setShouldRasterize,setShadowOffsetsetShadowPath. 没有它们也能正常工作。

于 2012-11-09T06:00:52.160 回答