ios - How to hide the line between items in UICollectionView -
ios - How to hide the line between items in UICollectionView -
i'm writing calendar using uicollectionview. don't know why line come out
this code create uicollectionview
#import "monthtableview.h" #import "monthtablecollectionviewcell.h" @implementation monthtableview static nsstring *scellidentifier = @"cellidentifier"; #pragma mark - view lifecycle -(monthtableview *)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { _arr_week = @[@"日",@"一",@"二",@"三",@"四",@"五",@"六",]; [self initsubview]; } homecoming self; } -(void)initsubview { uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc]init]; flowlayout.minimuminteritemspacing = 0; flowlayout.minimumlinespacing = 0; uicollectionview *col_month = [[uicollectionview alloc]initwithframe:cgrectmake(5, 5, self.frame.size.width - 10, self.frame.size.height - 10) collectionviewlayout:flowlayout]; col_month.datasource = self; col_month.delegate = self; [self addsubview:col_month]; [col_month registerclass:[monthtablecollectionviewcell class] forcellwithreuseidentifier:scellidentifier]; } #pragma mark - uicollectionview delegate -(nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { homecoming 2; } -(nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { if (section == 0) { homecoming 7; } else { homecoming 5*7; } } -(cgsize)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout *)collectionviewlayout sizeforitematindexpath:(nsindexpath *)indexpath { cgfloat width = collectionview.frame.size.width / 7; homecoming cgsizemake(width, width); } -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { monthtablecollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:scellidentifier forindexpath:indexpath]; //debug if (indexpath.section == 0) { cell.backgroundcolor = [uicolor colorwithred:239/255.0 green:239/255.0 blue:239/255.0 alpha:1]; [cell.btn_day settitle:[nsstring stringwithformat:@"%@",_arr_week[indexpath.row]] forstate:uicontrolstatenormal]; } else { cell.btn_day.backgroundcolor = [uicolor whitecolor]; [cell.btn_day settitle:[nsstring stringwithformat:@"%ld",indexpath.row] forstate:uicontrolstatenormal]; } homecoming cell; } @end
and here custom cell
#import "monthtablecollectionviewcell.h" @implementation monthtablecollectionviewcell -(monthtablecollectionviewcell *)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { [self initsubviews]; } homecoming self; } -(void)initsubviews { _btn_day = [uibutton buttonwithtype:uibuttontypesystem]; _btn_day.frame = cgrectmake(0, 0, self.frame.size.width, self.frame.size.height); [self addsubview:_btn_day]; } @end
there nil in .h file declaring vars btw i'm using xcode6.
i think collectionview background colour showing through. resolve by;
[col_month setbackgroundcolor:[uicolor whitecolor]];
hope helps.
ios objective-c uicollectionview uicollectionviewcell uicollectionviewlayout
Comments
Post a Comment