From ec67dd545dc6daa97f02b8fb6ffb0d9ca364c952 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 14 Dec 2015 16:46:48 +0800 Subject: [PATCH] better logic for set socialWork in ProfileSocialAccount --- .../ProfileSocialAccountImagesCell.swift | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift index 642f7454..baef91c4 100644 --- a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift +++ b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift @@ -27,6 +27,36 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell { return } + // 对于从左到右排列,且左边的最新,要处理数量不足的情况 + + var shots: [DribbbleWork.Shot?] = dribbbleWork.shots.map({ $0 }) + + let imageViews = [ + imageView3, + imageView2, + imageView1, + ] + + // 不足补空 + if shots.count < imageViews.count { + + let empty: [DribbbleWork.Shot?] = Array(0..<(imageViews.count - shots.count)).map({ _ in + return nil + }) + + shots.insertContentsOf(empty, at: 0) + } + + for i in 0..