I want to add some Layers on my imageView to make an animation. I am facing a problem that don't know how to scale fit layer.content from images. The following are my code:
CALayer *topLayer = [[CALayer alloc] init];
topLayer.masksToBounds = YES;
topLayer.backgroundColor = [[UIColor whiteColor] CGColor];
[imageView.layer addSublayer:topLayer] ;
topLayer.contents = (id)[[UIImage imageNamed:@"test.jpg"] CGImage];
Thank you.