• AVfoundation中焦距的设置(slider实现拉近拉远镜头) -自定义UISlider


    首先设置一个slider

    UISlider focusSlider = [[UISlideralloc]initWithFrame:CGRectMake(60,_bottomView.frame.origin.y-60,200,20)];

        [focusSlideraddTarget:selfaction:@selector(AdjustFocusAction:)forControlEvents:UIControlEventValueChanged];

        [focusSlidersetThumbImage:[UIImageimageNamed:@"camera_view_slider_take_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetMinimumTrackImage:[UIImageimageNamed:@"camera_view_sliderbar_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetMaximumTrackImage:[UIImageimageNamed:@"camera_view_sliderbar_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetBackgroundColor:[UIColorclearColor]];

        [focusSlidersetMaximumValue:1];

        [focusSlidersetMinimumValue:0];

        [focusSlider setValue:0.0];

        [self.viewaddSubview:focusSlider];

    以下做一下有关相机的设置(只写出来了其中一部分,并非全部)

    preview = [AVCaptureVideoPreviewLayerlayerWithSession:self.session];

        self.preview.frame =CGRectMake(0,0, self.cameraView.frame.size.width,self.cameraView.frame.size.height);

        [self.previewsetPosition:CGPointMake(CGRectGetMidX(self.cameraView.bounds),CGRectGetMidY(self.cameraView.bounds))];

       

        self.preview.videoGravity =AVLayerVideoGravityResize;

        [self.cameraView.layeraddSublayer:self.preview];


    captureOutput(AVCaptureStillImageOutput*)[self.session.outputsobjectAtIndex:0];

     

    focusConnection =[captureOutput connectionWithMediaType:AVMediaTypeVideo];    

                                                              

    调节焦距

     

    -(void)AdjustFocusAction:(id)sender

    {

        [UIViewanimateWithDuration:0.025animations:^{

            [self.previewsetAffineTransform:CGAffineTransformMakeScale([(UISlider *)sendervalue]+1, [(UISlider *)sendervalue]+1)];

            focusConnection.videoScaleAndCropFactor = [(UISlider *)sendervalue]+1;

        }];


    }

  • 相关阅读:
    CSS 动画示例
    CSS3 学习过程中还需要再次重点的
    CSS3 transform
    CSS 用before和after伪类选择器制作阴影
    CSS 制作的导航菜单
    Iconfont-阿里巴巴矢量库下载的字体
    HTML 5 <meta> 标签
    采购订单暂存和持有相关的问题?
    JS 基础
    LaTeX+TexStudio安装与使用
  • 原文地址:https://www.cnblogs.com/allanliu/p/4277438.html
Copyright © 2020-2023  润新知