-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
I wanted 3 boxes in a single row with the same size. When user taps on any box, it must get enlarged & the other items have to get aligned accordingly.
I am using the same code given in RFQuiltLayout, but made a few changes as given below.
- (void)viewDidLoad {
.....
RFQuiltLayout* layout = (id)[self.collectionView collectionViewLayout];
layout.direction = UICollectionViewScrollDirectionVertical;
layout.blockPixels = CGSizeMake(97,97);
[self.collectionView reloadData];
}
- (void) setNumberArrays {
[self.numbers removeAllObjects];
[self.numberWidths removeAllObjects];
[self.numberHeights removeAllObjects];
for (NSInteger i = 0; i< [[self.entries objectAtIndex:0] count]; i++) {
[self.numbers addObject:@(i)];
if (i == AppDelegateObj.bigBoxIndex) {
[self.numberWidths addObject:@(2)];
[self.numberHeights addObject:@(2)];
}
else {
[self.numberWidths addObject:@(1)];
[self.numberHeights addObject:@(1)];
}
}
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (AppDelegateObj.bigBoxIndex == -1) {
AppDelegateObj.bigBoxIndex = indexPath.row;
}
else {
AppDelegateObj.bigBoxIndex = -1;
}
[self setNumberArrays];
if(!self.numbers.count || indexPath.row > self.numbers.count) return;
if(isAnimating) return;
isAnimating = YES;
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadData];
} completion:^(BOOL done) {
isAnimating = NO;
}];
}
When user taps on a box, I am just reassigning the arrays 'self.numbers', 'self.numberWidths', 'self.numberHeights' & reloading the UICollectionView.
Suppose user taps on 2, as per the current code the below is happening,
But I want the output to look like,
Please suggest what is the change to be made on code. I tried a lot to change. But failed :(
Metadata
Metadata
Assignees
Labels
No labels


