iOS框架AVFoundation实现相机拍照、录制视频

2020-01-21 05:31:47丽君

点击屏幕对焦:

 


//点击屏幕对焦 
-(void)focusTap:(UIGestureRecognizer *)tap{ 
 CGPoint tapPoint = [tap locationInView:self.view]; 
  
  
 float Y = tapPoint.y; 
 if (Y<60 || Y>([UIScreen mainScreen].bounds.size.height-100)) { 
  return; 
 } 
  
 [iDevice lockForConfiguration:nil]; 
 if ([iDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]) { 
  [iDevice setFocusPointOfInterest:CGPointMake(tapPoint.x/self.view.frame.origin.x, tapPoint.y/self.view.frame.origin.y)]; 
  [iDevice setFocusMode:AVCaptureFocusModeAutoFocus]; 
 } 
 [iDevice unlockForConfiguration]; 
  
 self.iFocusImgView.center = tapPoint; 
 self.iFocusImgView.hidden = NO; 
 [UIView animateWithDuration:0.3 animations:^{ 
  self.iFocusImgView.transform = CGAffineTransformMakeScale(1.25, 1.25); 
 }completion:^(BOOL finished) { 
  [UIView animateWithDuration:0.5 animations:^{ 
   self.iFocusImgView.transform = CGAffineTransformIdentity; 
  } completion:^(BOOL finished) { 
   self.iFocusImgView.hidden = YES; 
  }]; 
 }]; 
} 

关于视频录制可以在Demo中查看。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。


注:相关教程知识阅读请移步到IOS开发频道。