我有一点我无法解决的问题。我真的希望有人可以帮助我。我想调整实时摄像机视图的大小并将其放在中心,使用下面的代码:
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, 0.5, 0.56206);
picker.cameraViewTransform = CGAffineTransformTranslate(picker.cameraViewTransform, 80, 120);
但我得到的只是屏幕左上角的1/2尺寸缩放视图。似乎“CGAffineTransformTranslate”什么都不做。即使我使用过,翻译也无效:
picker.cameraViewTransform = CGAffineTransformMake(1, 0, 0, 1, 80, 120);
翻译部分似乎对实时摄像机视图没有影响。 希望有人能够启发我。
感谢。
答案 0 :(得分:5)
我在同一条船上。我所做的是物理移动拾取器框架。
[picker.view setFrame:CGRectMake(xOffset,yOffset,picker.view.frame.size.width,picker.view.frame.size.height)];
答案 1 :(得分:1)
我一直在反对同样的问题。我已确认缩放和旋转预览有效,但翻译似乎被忽略。我推测在设置变换时,CGAffineTransform的tx,ty部分将被忽略。这是iPhone OS v3.1.2。我现在没有其他操作系统版本可供测试。
答案 2 :(得分:-1)
我得到了解决方案。 必须在消息上设置:
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
示例代码:
#pragma mark -
#pragma mark UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
CGFloat width = [[self view] bounds].size.width;
CGFloat height = width/4*3;
CGSize sizeOfCamera = CGSizeMake(width, height);
CGAffineTransform t = CGAffineTransformMakeScale(0.5, 0.5);
[picker setCameraViewTransform:t];
// Now the image is automatically aligned to center.
// Translation matrix also can be applied, but didn't use because it's already aligned to center.
}