Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Latest commit

 

History

History

001-scroll-card

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Scroll Card

Demo

Scroll Card - demo

Introduction

  1. 图片水平滚动。
  2. 根据位置有缩放效果。
  3. 屏幕中间的图片会停到中间的位置。
  4. UISegmentedControl

Problem

1

This is likely occurring because the flow layout subclass _01_scroll_card.CustomLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

XCode 7: Copy Layoutattributes

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
    let attributes = super.layoutAttributesForElementsInRect(rect)
    var attributesCopy = [UICollectionViewLayoutAttributes]()
    for itemAttributes in attributes! {
        let itemAttributesCopy = itemAttributes.copy() as! UICollectionViewLayoutAttributes
        // add the changes to the itemAttributesCopy                       
        attributesCopy.append(itemAttributesCopy)
    }

    return attributesCopy
}

Reference