0

I have an ASNetworkImageNode that goes inside of a collection view that has a constrainedSize of (320, 320), but after measuring the log shows that image.calculatedSize is (375, 375). Is there something I'm doing wrong here?

#pragma mark - ASCellNode Delegate

- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
{
    CGSize availableSize = CGSizeMake(constrainedSize.height, constrainedSize.height);
    CGSize imageSize = [image measure:availableSize];

    NSLog(@"constrainedSize width: %lf and height: %lf", availableSize.width, availableSize.height);

    NSLog(@"measured image size width: %lf and height: %lf", imageSize.width, imageSize.height);

    return imageSize;
}

- (void)layout
{
    CGSize imageSize = image.calculatedSize;
    image.frame = CGRectMake(0, 0, imageSize.width, imageSize.height);
}
jimmy
  • 159
  • 2
  • 7

1 Answers1

0

ASImageNodes by default are going to return the size of the image they are loading, you need to set the frame of the image to be the desired size, instead of:

image.frame = CGRectMake(0, 0, imageSize.width, imageSize.height);

use

image.frame = CGRectMake(0, 0, bounds.width, bounds.height)

Or make sure that the image you're downloading is the exact size you're looking for.