From 07584598450fb0cb5f458775560d0cc4e644dfbf Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 12 May 2015 06:01:15 +0800 Subject: [PATCH] profile skills left align --- Yep/ViewControllers/Profile/ProfileLayout.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Yep/ViewControllers/Profile/ProfileLayout.swift b/Yep/ViewControllers/Profile/ProfileLayout.swift index de0aaad3..ac9b491b 100644 --- a/Yep/ViewControllers/Profile/ProfileLayout.swift +++ b/Yep/ViewControllers/Profile/ProfileLayout.swift @@ -10,6 +10,8 @@ import UIKit class ProfileLayout: UICollectionViewFlowLayout { + let leftEdgeInset: CGFloat = 38 + override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? { let layoutAttributes = super.layoutAttributesForElementsInRect(rect) as! [UICollectionViewLayoutAttributes] let contentInset = collectionView!.contentInset @@ -69,10 +71,12 @@ class ProfileLayout: UICollectionViewFlowLayout { for attributes in rowCollection { var itemFrame = attributes.frame - if CGRectEqualToRect(previousFrame, CGRectZero) { - itemFrame.origin.x = alignmentOffsetX - } else { - itemFrame.origin.x = CGRectGetMaxX(previousFrame) + minimumInteritemSpacing + if attributes.representedElementCategory == .Cell && (attributes.indexPath.section == ProfileViewController.ProfileSection.Master.rawValue || attributes.indexPath.section == ProfileViewController.ProfileSection.Learning.rawValue) { + if CGRectEqualToRect(previousFrame, CGRectZero) { + itemFrame.origin.x = leftEdgeInset + } else { + itemFrame.origin.x = CGRectGetMaxX(previousFrame) + minimumInteritemSpacing + } } attributes.frame = itemFrame