我想在我的應用程序中使用CSStickyHeaderFlowLayout製作視差照片效果 - https://github.com/jamztang/CSStickyHeaderFlowLayout/ 和Swift語言。CSStickyHeaderFlowLayout swift
我已經安裝了必要的波德的文件中,添加#進口「CSStickyHeaderFlowLayout.h」我的「APPNAME」 -Bridging-Header.h文件,並實施此方法:
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:
CSStickyHeaderFlowLayout *layout = (id)self.collectionViewLayout;
if ([layout isKindOfClass:[CSStickyHeaderFlowLayout class]]) {
layout.parallaxHeaderReferenceSize = CGSizeMake(320, 200);
}
在我看來,在這之後,我的效果應該起作用。我對嗎?或者我錯過了什麼?
感謝您的幫助, m.af