zxing摄像头支持横屏

 

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
  
    float space=(SCREEN_WIDTH>SCREEN_HEIGHE?(SCREEN_WIDTH-SCREEN_HEIGHE):(SCREEN_HEIGHE-SCREEN_WIDTH))/2;
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    self.capture.delegate = self;
    self.capture.layer.anchorPoint=CGPointMake(0.5, 0.5);
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
        self.capture.layer.frame = CGRectMake(-space, space, SCREEN_WIDTH,SCREEN_HEIGHE);
        CATransform3D transform = CATransform3DMakeRotation(0, 0, 0, 1);
        self.capture.layer.transform = transform;
        NSLog(@"==%f",SCREEN_WIDTH);
    }else{
        self.capture.layer.position=self.view.center;
        self.capture.layer.frame = CGRectMake(space, -space, SCREEN_WIDTH,SCREEN_HEIGHE);
        CATransform3D transform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
        self.capture.layer.transform = transform;
        NSLog(@"--%f",SCREEN_WIDTH);
    }
}

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页