Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use Flow Layout in UICollectionview

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 592
    Comment on it

    cells in UICollectionview can be of same Size or different sizes, so we use the flow layout. UICollectionViewFlowLayout manage items into a grid with header and footer view for every section.

    Here we define the flow layout--

    -(void)viewDidLoad
        {
            [super viewDidLoad];
            [self.collectionView registerClass:[CellClass class] forCellWithReuseIdentifier:@"identifier"];
            self.collectionView.backgroundColor = [UIColor clearColor];
    
            // Configure flow layout
            self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
            [self.flowLayout setItemSize:CGSizeMake(width, height)];
            [self.flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
            self.flowLayout.minimumInteritemSpacing = 0.0f;
            [self.collectionView setCollectionViewLayout:self.flowLayout];
            self.collectionView.bounces = YES;
            [self.collectionView setShowsHorizontalScrollIndicator:NO];
            [self.collectionView setShowsVerticalScrollIndicator:NO];
        }
    

    Here flow layout is the property of UICollectionviewFlowLayout. The method below sets the spacing between sections within the collection view.

    - (UIEdgeInsets)collectionView:
    (UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
        return UIEdgeInsetsMake(0, 0, 0, 0);
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: