Я хочу сфокусировать и изменить кадр последней ячейки видимой ячейки коллекцииView.Как сфокусировать последнюю ячейку видимой ячейки коллекции?
Я хочу, чтобы поведение в виде коллекции выглядело как this.
Я нашел library, которые меняют первую ячейку просмотра коллекции, но я хочу изменить кадр последней ячейки. Эта библиотека использует раскладку потока.
override func prepareLayout() {
cache.removeAll(keepCapacity: false)
let standardHeight = UltravisualLayoutConstants.Cell.standardHeight
let featuredHeight = UltravisualLayoutConstants.Cell.featuredHeight
var frame = CGRectZero
var y: CGFloat = 0
for item in 0..<numberOfItems {
// 1
let indexPath = NSIndexPath(forItem: item, inSection: 0)
let attributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
// 2
attributes.zIndex = item
var height = standardHeight
// 3
if indexPath.item == featuredItemIndex
{
// 4
let yOffset = standardHeight * nextItemPercentageOffset
y = collectionView!.contentOffset.y - yOffset
height = featuredHeight
} else if indexPath.item == (featuredItemIndex + 1) && indexPath.item != numberOfItems {
// 5
let maxY = y + standardHeight
height = standardHeight + max((featuredHeight - standardHeight) * nextItemPercentageOffset, 0)
y = maxY - height
}
// 6
frame = CGRect(x: 0, y: y, width: width, height: height)
//print("Item : \(item) : \(frame)");
attributes.frame = frame
cache.append(attributes)
y = CGRectGetMaxY(frame)
}
}
library использует функцию выше, чтобы изменить рамку всех элементов.
Может ли кто-нибудь сказать мне, как я могу достичь this.
https://github.com/Ramotion/folding-cell – magid
он использовал ту же технику, которую Вы используете только разница, нажав на ячейку. – magid
@magid Спасибо. Я попробую. Надеюсь, это сработает. –