SCSectionBackground:如何在UICollectionView中的单元格或节中添加背景色

时间:2021-05-15 15:08:03
【文件属性】:
文件名称:SCSectionBackground:如何在UICollectionView中的单元格或节中添加背景色
文件大小:3.98MB
文件格式:ZIP
更新时间:2021-05-15 15:08:03
Swift UICollectionView部分背景 该项目显示了如何将颜色应用于UICollectionView上的背景部分(或单元格)。 该代码是用Swift编写的,并受到Eric (Objective-C )的启发。 您可以根据单元格的NSIndexPath应用不同的颜色。 这是一个UICollectionView的示例,其中UICollectionView 4个部分,3个具有偶数部分绿色背景的单元格和7个位于奇数部分蓝色背景的单元格。 它是如何工作的? 这个想法是重写UICollectionViewLayoutAttributes以添加颜色属性。 然后重写UICollectionReusableView将颜色应用于视图背景。 十分简单 :) class SCSBCollectionViewLayoutAttributes : UICollectionViewLayoutAttribut
【文件预览】:
SCSectionBackground-master
----SCSectionBackground.xcodeproj()
--------project.xcworkspace()
--------xcuserdata()
--------project.pbxproj(22KB)
----Images()
--------SCSectionBackground.png(32KB)
--------Screen Shot.png(611KB)
--------SCSectionBackground_Example.png(93KB)
--------SCSectionBackground_small.png(35KB)
--------SCSectionBackground_debugViewHierarchy.png(38KB)
----SCSectionBackgroundTests()
--------SCSectionBackgroundTests.swift(1KB)
--------Info.plist(733B)
----LICENSE(1KB)
----README.md(3KB)
----SCSectionBackgroundUITests()
--------Info.plist(733B)
--------SCSectionBackgroundUITests.swift(1KB)
----SCSectionBackground()
--------ViewController.swift(529B)
--------SectionBackgroundCollectionViewController.swift(2KB)
--------Info.plist(1KB)
--------AppDelegate.swift(2KB)
--------ExampleFlowLayout.swift(3KB)
--------ExampleViewController.swift(3KB)
--------SectionBackgroundFlowLayout.swift(4KB)
--------Base.lproj()
--------Assets.xcassets()
--------Extensions.swift(385B)

网友评论