I want to create a ImageView Object , But ,when I use contentRect property to create , the result have any shadow , help me .
Look this code :
CALayer *blueLayer = [CALayer layer];
blueLayer.frame = CGRectMake(50.0f, 50.0f, 100.0f, 200.0f);
blueLayer.backgroundColor = [UIColor blueColor].CGColor;
UIImage *image = [UIImage imageNamed:@"vclrs_me_wodeshoucang"] ;
CGImageRef imageRef = image.CGImage ;
blueLayer.contents = (__bridge id _Nullable)imageRef ;
blueLayer.contentsGravity = kCAGravityCenter ;
blueLayer.contentsRect = CGRectMake(0, 0, 2, 2) ;
blueLayer.contentsScale = image.scale ;
[self.layerView.layer addSublayer:blueLayer];

https://developer.apple.com/reference/quartzcore/calayer/1410866-contentsrect?language=objc
According to above documentation
Defaults to the unit rectangle (0.0, 0.0, 1.0, 1.0).
If pixels outside the unit rectangle are requested, the edge pixels of the contents image will be extended outwards.
If an empty rectangle is provided, the results are undefined.
So according to it it will give output like this