mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Add custom collection view layout example project
This commit is contained in:
37
examples/CustomCollectionView/Sample/ImageCellNode.m
Normal file
37
examples/CustomCollectionView/Sample/ImageCellNode.m
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// ImageCellNode.m
|
||||
// Sample
|
||||
//
|
||||
// Created by McCallum, Levi on 11/22/15.
|
||||
// Copyright (c) 2015 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ImageCellNode.h"
|
||||
|
||||
@implementation ImageCellNode {
|
||||
ASImageNode *_imageNode;
|
||||
}
|
||||
|
||||
- (id)initWithImage:(UIImage *)image
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_imageNode = [[ASImageNode alloc] init];
|
||||
_imageNode.image = image;
|
||||
[self addSubnode:_imageNode];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
||||
{
|
||||
[_imageNode measure:constrainedSize];
|
||||
return constrainedSize;
|
||||
}
|
||||
|
||||
- (void)layout
|
||||
{
|
||||
_imageNode.frame = CGRectMake(0, 0, _imageNode.calculatedSize.width, _imageNode.calculatedSize.height);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user