。h
@interface HJDatePicker : UIView<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
-(id)init;
@property(nonatomic,strong)UICollectionView* collection;
@property(nonatomic,assign)CGRect myframe;
@property(nonatomic,strong)id<Sendmessage> sendDelegate;
。m-(id)init{
CGFloat mainwith=[UIScreenmainScreen].bounds.size.width;
CGFloat mainheight=[UIScreenmainScreen].bounds.size.height;
CGRect frame=CGRectMake(0, mainheight/2, mainwith, mainheight/2);
self=[superinitWithFrame:frame];
_myframe=frame;
if (self) {
self.backgroundColor=[UIColorwhiteColor];
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc ] init ];
self.collection=[[UICollectionViewalloc]initWithFrame:_myframe collectionViewLayout:layout];
[self.collectionregisterClass :[ UICollectionViewCellclass ] forCellWithReuseIdentifier :_CELL ];
self.collection.center=CGPointMake(_myframe.size.width/2,_myframe.size.height/2);
self.collection.delegate=self;
self.collection.dataSource=self;
[selfaddSubview:self.collection];
[selfbecomeFirstResponder];
}