Please help me how I can add labels horizontally and similarly buttons horizontally but each button should align at down of each label like a another section. This should happen dynamically in the header of the UICollectionView as the number of labels and buttons is according to my data.
I want to make a excel kind of layout and in header I want to show the above controls.
Thanks in advance!
I have done this-
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableview = nil;
if (kind == UICollectionElementKindSectionHeader) {
DepartmentCollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
for (int i=0; i<_officelist.count; i++) {
UILabel *label = [[UILabel alloc] init];
label.tag = i+1;
label.text=[NSString stringWithFormat:@"%@",_officelist[i]];
[self.roadmapCollectionView addSubview:label];
}
reusableview = headerView;
}
return reusableview;
}
OfficeList is my array containing the list which I want to display in each label at index value.