Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you want to create cell as per you image aspect ratio #37

Open
mahendra-lariya opened this issue Mar 7, 2019 · 0 comments
Open

If you want to create cell as per you image aspect ratio #37

mahendra-lariya opened this issue Mar 7, 2019 · 0 comments

Comments

@mahendra-lariya
Copy link

mahendra-lariya commented Mar 7, 2019

func collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo {
let W = self.view.frame.size.width/2 // - 10
let rowHeight: CGFloat = self.view.frame.size.width/12 //W //93
let columns = [ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W)]
let geometryInfo = ADMozaikLayoutSectionGeometryInfo(rowHeight: rowHeight,
columns: columns,
minimumInteritemSpacing: 1,
minimumLineSpacing: 1,
sectionInset: UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 0),
headerHeight: 1, footerHeight: 1)
return geometryInfo
}

func collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize {
    let image = photos[indexPath.row].image
    let aspectratio = image.size.width/image.size.height
    
    if aspectratio == 1/1 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 6)
    }
    if aspectratio == 2/3 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 9)
    }
    if aspectratio == 3/2 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 4)
    }
    if aspectratio == 2/1 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 3)
    }
    if aspectratio == 1/2 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 12)
    }
    else {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 6)
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant