티스토리 뷰

반응형


https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/UsingtheFlowLayout/UsingtheFlowLayout.html


=> 위의 문서를 보면 estimatedspacing이랑 실제 그려질때 actual spacing이랑 다른 것을 볼 수 있다

    

     스택오버플로우로 찾아본 결과,,! 밑의 코드로 actual spacing을 확인해볼 수 있다 


    func calculateActualSpacing()->CGFloat?{

        let firstIndex =  IndexPath(item: 0, section: 0)

        let secondIndex = IndexPath(item: 1, section: 0)

        if let att1 = collectionView.layoutAttributesForItem(at: firstIndex),

            let att2 = collectionView.layoutAttributesForItem(at: secondIndex) {

            let actualSpace = att2.frame.minX - att1.frame.maxX

            

            return actualSpace

        }

        

        return nil

    }




https://bradbambara.wordpress.com/2014/05/24/getting-started-with-custom-uicollectionview-layouts/

>> 커스텀 레이아웃도 만들어봐야징~ 

반응형
댓글