gpt4 book ai didi

objective-c - UICollectionViewCell 边框/阴影

转载 作者:太空狗 更新时间:2023-10-30 03:09:07 26 4
gpt4 key购买 nike

构建 iPad 应用程序时,如何在 UICollectionViewCell 周围绘制边框?

更多细节:我实现了一个扩展 UICollectionViewCell 的 ProductCell 类。现在,我想分配一些花哨的细节,例如边框,阴影等。但是,当尝试使用类似 this here 的东西时,Xcode 告诉我接收器类型“CALayer”是前向声明。

最佳答案

只是为了更多的实现:

#import <QuartzCore/QuartzCore.h>

在你的.m

确保你的类实现

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; 

因为这是设置单元格的地方。

然后您可以更改 cell.layer.background(仅在导入 quartz 后可用)

见下文

- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MyCollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"pressieCell" forIndexPath:indexPath];
//other cell setup here

cell.layer.borderWidth=1.0f;
cell.layer.borderColor=[UIColor blueColor].CGColor;

return cell;
}

关于objective-c - UICollectionViewCell 边框/阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13121294/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com