二维码限制扫描区域

  //scopeRect:限制的扫描区域范围

 _metadataOutput.rectOfInterest = [self rectOfInterestByScanViewRect:scopeRect];

  

}

 

- (CGRect)rectOfInterestByScanViewRect:(CGRect)rect {

    

    CGFloat width = SCREEN_WIDTH;

    CGFloat height = SCREEN_HEIGHT;

    

    CGFloat x = rect.origin.y/ height;

    CGFloat y = rect.origin.x/ width;

    

    CGFloat w = CGRectGetHeight(rect) / height;

    CGFloat h = CGRectGetWidth(rect) / width;

    

    return CGRectMake(x, y, w, h);

}

转载于:https://www.cnblogs.com/pioneerMax/p/11171802.html

你可能感兴趣的:(二维码限制扫描区域)