2013-08-22 18 views
6

Please help me come cambiare le dimensioni del fotogramma AVCaptureVideoPreviewLayer eCome cambiare AVCaptureVideoPreviewLayer altezza e la larghezza

sto passando Height =100px ; and width = 300px.

se passo la dimensione altezza 100 di larghezza non cambia a 300px

Ecco codice:

AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session]; 
    previewLayer.frame = CGRectMake(20, 50, 300, 100); 
    self.view.frame=CGRectMake(20, 50, 300, 100); 


    CGRect layerRect = [[[self view] layer] bounds]; 
    [previewLayer setBounds:layerRect]; 
    [previewLayer setPosition:CGPointMake(CGRectGetMidX(layerRect),CGRectGetMidY(layerRect))]; 
    [[[self view] layer] addSublayer:previewLayer]; 
    [previewView.layer addSublayer:previewLayer]; 

risposta

5
@property (nonatomic, retain) AVCaptureVideoPreviewLayer *prevLayer; 

Poi:

self.prevLayer = [AVCaptureVideoPreviewLayer layerWithSession: self.captureSession]; 
    self.prevLayer.frame = yourRect; 
[self.view.layer addSublayer: self.prevLayer]; 

è esso.

+0

sì, è funzionante. –