FLYNNLABAboutMeCodingActivityStudy 2024초등수학
UICollectionView reload without animation
swift, ios

ISSUE

UICollectionView에서 datasource 변경후 반영하려고 하면 자동으로 애니메이션효과(페이드인)가 적용된다. 이 부분을 해결 할수 있는 방법을 찾아보니 여러가지가 나오는데 그중 ios7 이상부터 지원되는 메소드를 소개한다.

RESOLVE

iOS7 이상만 지원하는 경우 performWithoutAnimation 메소드를 활용하면 된다.

// swift
UIView.performWithoutAnimation({
    if let collectionView = self.collectionView {
        collectionView.reloadSections(NSIndexSet(index: EndSectionType.Content.toRaw()))
    }
})

LINK

http://stackoverflow.com/questions/14094684/avoid-animation-of-uicollectionview-after-reloaditemsatindexpaths