I have an image which measures 480px x 480px and I'd like to display it in a view which measures 375px x 375px using CGContextDrawImage
as below. At the moment the image doesn't scale to fit the view - it is drawn at full size. How can I adjust the code below to scale the image to fit the view please?
self.image = [UIImage imageNamed:@"image2.png"];
CGContextRef layerContext = CGLayerGetContext(drawingLayer);
CGContextSaveGState(layerContext);
UIGraphicsBeginImageContext (self.viewRect.size);
CGContextTranslateCTM(layerContext, 0, self.image.size.width);
CGContextScaleCTM(layerContext, 1.0, -1.0);
CGContextDrawImage(layerContext, self.viewRect, self.image.CGImage);
UIGraphicsEndImageContext();
CGContextRestoreGState(layerContext);