相关疑难解决方法(0)

Google Now喜欢iOS上的界面

所以,我非常喜欢Android上的Google Now卡片界面.最近它甚至还来到了iOS.

是否有任何教程或示例项目可以帮助我为我的iOS应用程序创建卡片界面?

根据我的研究,我已经能够使用自定义UICollectionViewFlowLayout复制"堆叠"卡.

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    NSArray *allAttributesInRect = [super layoutAttributesForElementsInRect:rect];

    CGPoint centerPoint = CGPointMake(CGRectGetMidX(self.collectionView.bounds), CGRectGetMidY(self.collectionView.bounds));

    for (UICollectionViewLayoutAttributes *cellAttributes in allAttributesInRect)
    {
        if (CGRectContainsPoint(cellAttributes.frame, centerPoint))
        {
            cellAttributes.transform = CGAffineTransformIdentity;
            cellAttributes.zIndex = 1.0;
        }
        else
        {
            cellAttributes.transform = CGAffineTransformMakeScale(0.75, 0.75);
        }
    }

    return allAttributesInRect;
}
Run Code Online (Sandbox Code Playgroud)

然后我将最小行间距设置为负值,使它们显示为"堆叠".

滚动时,我希望卡片保持在底部,只有一辆汽车可以向上扩展并在屏幕中居中.然后我会将该卡从屏幕上滚动,堆栈中的下一张"卡片"将从堆栈向上滚动并在屏幕上居中.我猜这会动态调整最小行间距?

iphone objective-c ios google-now

4
推荐指数
1
解决办法
9210
查看次数

标签 统计

google-now ×1

ios ×1

iphone ×1

objective-c ×1