iOS-自定义响应部分索引列表

时间:2019-04-28 10:59:34

标签: ios swift uikit uilocalizedcollation

我正在创建自定义部分索引列表。当没有像苹果公司那样的所有产品都没有空间时,此列表必须减少瓷砖的数量。磁贴列表在已删除的项目之间放置一个•。

The tiles on the iPhone SE. The tiles on the iPhone 8 Plus

我创建了以下代码,但是我找不到如何均匀删除A和Z#之间的项目的方法。

// Get the frame height.
// iPhone SE
let frameHeight:CGFloat = 236
// iPhone 8 Plus
//let frameHeight:CGFloat = 318

// Get the required tile height.
let tileHeight:CGFloat = 14.1

// Get the tiles and count.
var indexTitles = UILocalizedIndexedCollation.current().sectionIndexTitles
let indexTitlesCount = CGFloat(indexTitles.count)

// Get the number of tiles that can fit in the space. For an iPhone SE is 16 items.
let maxTileSpaceCount = floor(frameHeight / tileHeight)
// Get the minimum number of tiles that have to be removed.
let minimumNumberOfTilesToRemove = (indexTitlesCount - maxTileSpaceCount)
...

0 个答案:

没有答案