tra*_*uan 6 objective-c calayer ios uicollectionview
我的集合视图单元结构如下所述

因为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
......................................................................
}
Run Code Online (Sandbox Code Playgroud)
当我在设备上运行应用程序时,会显示阴影.但是,我的标签文字很模糊.请查看从我的设备中拍摄的以下图像

如果我取消注释用于删除阴影的波德块,则文本如下图所示

我......完全迷失了.有没有人对这个问题有任何想法.请帮忙
您正在栅格化图层,但默认的栅格化比例为1.0.视网膜显示需要设置为2.0,否则图层只显示半分辨率.
cell.layer.rasterizationScale=[[UIScreen mainScreen] scale];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1221 次 |
| 最近记录: |