CSStickyHeaderFlowLayout很快 [英] CSStickyHeaderFlowLayout swift

查看:204
本文介绍了CSStickyHeaderFlowLayout很快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CSStickyHeaderFlowLayout
在我的应用中制作视差照片效果 - https:// github.com/jamztang/CSStickyHeaderFlowLayout/
和Swift语言。

I'm trying to make parallax photo effect in my app using CSStickyHeaderFlowLayout - https://github.com/jamztang/CSStickyHeaderFlowLayout/ and Swift language.

我已安装必要的Pod文件,添加#importCSStickyHeaderFlowLayout.h到我的appName-Bridging-Header.h文件,并实现了这个方法:

I have installed necessary Pod's file, add #import "CSStickyHeaderFlowLayout.h" to my "appName"-Bridging-Header.h file, and implemented this method:

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {

    var cell: UICollectionViewCell = UICollectionViewCell(frame: CGRectMake(0, 0, 400, 200));
    var imageView: UIImageView = UIImageView();
    var image: UIImage  = UIImage(named: "news2.jpg")!;
    imageView.image = image;
    cell.addSubview(imageView);
    return cell;

}

但现在我很难翻译这个Obj-C代码到Swift:

but now I have difficulties to translate this Obj-C code to Swift:

CSStickyHeaderFlowLayout *layout = (id)self.collectionViewLayout;
if ([layout isKindOfClass:[CSStickyHeaderFlowLayout class]]) {
    layout.parallaxHeaderReferenceSize = CGSizeMake(320, 200);
}

在我看来,在那一步之后,我的效果应该有效。我对吗?或者我错过了什么?

In my opinion after that step my effect should works. Am I right? Or I have missed something?

感谢您的帮助,
m.af

Thanks for help, m.af

推荐答案

你应该能够在Swift中这样做吗?

You should be able to do it like this in Swift

if let layout = self.collectionViewLayout as? CSStickyHeaderFlowLayout {
    layout.parallaxHeaderReferenceSize = CGSizeMake(320, 200)
}

这篇关于CSStickyHeaderFlowLayout很快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆