I'm trying to scale an AVCaptureVideoPreviewLayer
so it displays a "zoomed in" preview from the camera; I can make this work using setAffineTransform:CGAffineTransformMakeScale(2.0f, 2.0f)
, but only once the layer is visible on screen. That is, the scale transform doesn't seem to take effect unless I call it (from within a CATransaction
) during a callback like viewDidAppear
.
What I'd really like to do is have the scale transform be applied prior to the layer becoming visible--e.g. at the time that I initialize it and add it to the UIView
--but all my attempts to do so have proven futile. If I set the transform at this point, and then attempt to read the value back once it is visible, it does appear to have the desired scale transform set -- yet it does not have any effect on the view. I'm new to iOS programming, so I'm sure there's something basic I'm missing here; any help is appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…