Ios 如何为UICollectionViewCell使用UITableViewCellAccessoryCheckmark单元格样式
我现在使用的是Ios 如何为UICollectionViewCell使用UITableViewCellAccessoryCheckmark单元格样式,ios,uicollectionview,Ios,Uicollectionview,我现在使用的是UICollectionView方法,目前已将设备照片集成到uicollectionviewcell中。我想为UICollectionViewCells添加单元格样式方法 UICollectionView是否有任何可用的单元格样式,如UITableViewCellAccessoryCheckmark?您可以创建UICollectionViewCell类并初始化要在单元格中显示的内容,如 CollectionViewCustomCell.h #import <UIKit/UIK
UICollectionView
方法,目前已将设备照片集成到uicollectionviewcell中。我想为UICollectionViewCells添加单元格样式方法
UICollectionView是否有任何可用的单元格样式,如
UITableViewCellAccessoryCheckmark
?您可以创建UICollectionViewCell类并初始化要在单元格中显示的内容,如
CollectionViewCustomCell.h
#import <UIKit/UIKit.h>
@interface CollectionViewCustomCell : UICollectionViewCell
@property (retain, nonatomic) UILabel* label;
@property (retain, nonatomic) UIImageView *myImageView;
@end
#import "CollectionViewCustomCell.m"
@implementation CollectionViewCustomCell
@synthesize label,myImageView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor blackColor];
label.font = [UIFont boldSystemFontOfSize:35.0];
label.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:label];;
myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 70, 70)];
myImageView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:myImageView];
}
return self;
}
@end
在cellForItemAtIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCustomCell *customcell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
customcell.label.text = @"Text";
customcell. myImageView.image = yourImage;
return customcell;
}
这只是一个想法。您可以将其他子视图添加到集合视图单元格。Collectionviewcell没有任何单元格样式。但是您可以定制CollectionViewCell以满足您的需要。谢谢。您能告诉我如何定制CollectionViewCell或任何链接吗?您可以看到我的答案。它只是一个想法,如何可以定制您的细胞。你也看到了,非常感谢,我会尽力让你知道的
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCustomCell *customcell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
customcell.label.text = @"Text";
customcell. myImageView.image = yourImage;
return customcell;
}