2012-05-08 48 views
4

iOS/Objective C相當新穎我正在對Apple的AVCam(視頻採集)示例代碼進行修改,並且希望模擬本機相機的翻轉動畫前後攝像頭。看起來好像這很容易,但我無法理解它是如何完成的。建議將受到歡迎。iOS SDK:在切換攝像頭時如何使視圖翻轉

謝謝!

馬克

回答

4

這確實是一個簡單的任務。您需要做的就是在更改previewView輸入之前調用transitionWithViewUIView

如果您的目標是iOS 8.0或更高版本,還可以輕鬆添加模糊效果。

在夫特:

let blurView = UIVisualEffectView(frame: previewView.bounds) 
blurView.effect = UIBlurEffect(style: .Light) 
previewView.addSubview(blurView) 

UIView.transitionWithView(previewView, duration: 0.4, options: .TransitionFlipFromLeft, animations: nil) { (finished) -> Void in 
    blurView.removeFromSuperview() 
} 

目的-C:

UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithFrame:_previewView.bounds]; 
blurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 
[_previewView addSubview:blurView]; 

[UIView transitionWithView:_previewView duration:0.4 options:UIViewAnimationOptionTransitionFlipFromLeft animations:nil completion:^(BOOL finished) { 
    [blurView removeFromSuperview]; 
}]; 
相關問題