Giter Site home page Giter Site logo

fmmosaiclayout's Introduction

CI Status Version License Platform

FMMosaicLayout is a mosiac collection view layout. There are a great number of media-based iOS applications that use UICollectionViewFlowLayout without any modifications. This lends itself to boring presentation, and unengaging interaction. FMMosaicLayout is a step in the right direction. Simply add this pod to your project, set your preferences and it will layout out your collection view cells in pretty mosaics. The algorithm behind this got its inspiration from this blog post.

Portrait Screenshot

Usage

FMMosaicLayout is very easy to use. Below is all you need to get going.

- (void)viewDidLoad {
    ...

    FMMosaicLayout *mosaicLayout = [[FMMosaicLayout alloc] init];
    self.collectionView.collectionViewLayout = mosaicLayout;

    ...
}

#pragma mark <FMMosaicLayoutDelegate>

- (NSInteger)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
    numberOfColumnsInSection:(NSInteger)section {

    return 2; // Or any number of your choosing.
}

It's also possible to set the layout via Interface Builder. To see a complete example implementation. Clone the repo, and run pod install from the Example directory. Then open up Example/FMMosaicLayout.xcworkspace.

Customization

In addition to the required protocol method collectionView:layout:numberOfColumnsInSection:, there are several optional methods you can implement from FMMosaicLayoutDelegate. You can see them in action in the example project.

Mosaic Cell Size
- (FMMosaicCellSize)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
        mosaicCellSizeForItemAtIndexPath:(NSIndexPath *)indexPath;

This allows you to specify when you want to place a large or small mosaic cell.

Section Insets
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
        insetForSectionAtIndex:(NSInteger)section;

Here you can specify a custom UIEdgeInsets for each section.

Interitem Spacing
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
        interitemSpacingForSectionAtIndex:(NSInteger)section;

Here you can specify the spacing between cells.

Header and Footer Support

Below are the optional methods you can make use of to customize your headers and footers. The first methods are to set the height of your header/footers.

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
 heightForHeaderInSection:(NSInteger)section;

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(FMMosaicLayout *)collectionViewLayout
 heightForFooterInSection:(NSInteger)section;

If you want your header and/or to overlay your mosaic cells implement the following methods below in your delegate and have them return YES. The default is NO.

- (BOOL)headerShouldOverlayContentInCollectionView:(UICollectionView *)collectionView
                                            layout:(FMMosaicLayout *)collectionViewLayout;

- (BOOL)footerShouldOverlayContentInCollectionView:(UICollectionView *)collectionView
                                            layout:(FMMosaicLayout *)collectionViewLayout;

Installation

FMMosaicLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "FMMosaicLayout"

License

FMMosaicLayout is available under the MIT license. See the LICENSE file for more info.

fmmosaiclayout's People

Contributors

jvillella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fmmosaiclayout's Issues

Change Cell Size ( or number of items in one column)

Hello, thank's this really simple and great Library and I need to know how can I change the cells size and use my costum size.
Also I've noticed that the number of cells in rows is always multiplier of 2 (2 cells, 4 cells, 8 cells ... in a row) and the big cell size is 2 cells for width and height.
So it will be more nicer if you allows user to define the number of cell in row and the big cell size (for example 3cell for height and 4 for width).
Also I'm ready to contribute in this project

ability to change number of image in one row

can you plz add the abilty to change the number of image in one row,
perexample i notice that always the number 1 row in contain 5 image,
no mare what
can you plz make the row more flexbile,

How to Add Header and Footer View?

Please show me how to add header and footer view in to your collection layout?
I try but cannot by this:

  • (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;

SWIFT.

Not an issue really but if you could issue this (see what i did there?) in swift, you would unlock the nth universe. Really. Like, seriously. All that aside, its a great control!

More options for cell size?

Hi there,

I was looking into this library, and one thing I saw is that it currently only seems to support two cell sizes.

Is there any chance this can be changed to allow the app to specify the size of a cell in number of columns and rows? That would make the system much more flexible and customizable.

Kind regards,

pieter

Add support for FMMosaicCellSizeTall and FMMosaicCellSizeWide.

Requesting two new sizes FMMosaicCellSizeTall and FMMosaicCellSizeWide.

The way I am imagining it is that FMMosaicCellSizeTall would be the height of two FMMosaicCellSizeSmall (and the width of one) and Wide would be the width of two (and the height of one).

How to add cell size medium ?

Thanks for the Code.

In your code cell size is big and small but I was trying to add another cell size Medium .
Can you please help me out.

Thank You

Calculate mosaic cell size placement to always end flush

Depending on how the mosaic cells are arranged, they don't always end flush with the bottom of the collection view. One way to solve this is with a better calculation of when to render a big or small-sized cell. Provide a mechanism to simply this for the end user.

issues with build.

if you run into compiler issues when using this framework, simply add #import <UIKit/UIKit.h> in the header file

setting numberOfColumnsInSection to odd number

Currently when we set the numberOfColumnsInSection the result view will have double the amount of columns we requested.

E.g. we set the value to 2 then there is 4 columns in the collectionview.

Due to this, we can't add odd number columns (e.g. 3,5,7 etc.)

Could you please address this issue.

Can't get the Example Project to work

Using XCode 6.3.1, Cocoapods is 0.37.2

I opened the "Example" project in XCode and hit the run button and it gives these errors:

diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

I tried going to the directory to install the files from pod. I tried pod install and this is what I got:

[!] Unable to satisfy the following requirements:

- `FMMosaicLayout (from `../`)` required by `Podfile`
- `FMMosaicLayout (from `../`)` required by `Podfile`
- `FMMosaicLayout (= 0.1.1)` required by `Podfile.lock`

I downloaded it through ZIP and did not change any of the files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.