在您的 VC.h 文件中
@interface VideoCaptureVC_iPhone : UIViewController
<UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
UIImagePickerController *picker;
NSTimer *videoTimer;
}
@property (nonatomic, retain) NSTimer *videoTimer;
在你的 vc.m 文件上
- (void)pickerCameraSnap:(id)sender{
NSLog(@"start camera capture and timer");
[picker startVideoCapture];
self.videoTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];
}
根据您的需要进行计算并在适当的位置更改文本@“TimeRemaining”我已经为横向视图旋转了文本!
-(void)changeValue{
UILabel *textNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
textNameLabel.center = CGPointMake(30,285);
textNameLabel.backgroundColor = [UIColor redColor];
textNameLabel.text = @"TimeRemaining";
textNameLabel.textColor = [UIColor whiteColor];
CGAffineTransform transformRotate = CGAffineTransformMakeRotation((M_PI / 2));
textNameLabel.transform = transformRotate;
UIView *myOverlay = [[UIView alloc] initWithFrame:self.view.bounds];
UIImage *overlayImg = [UIImage imageNamed:@"CameraOverlay"];
UIImageView *overlayBg;
overlayBg = [[UIImageView alloc] initWithImage:overlayImg];
[myOverlay addSubview:overlayBg];
[myOverlay addSubview:textNameLabel];
[picker setCameraOverlayView:myOverlay];
}
最后停止计时器
- (void)stopCamera:(id)sender{
NSLog(@"stop camera");
[self.videoTimer invalidate];
[picker stopVideoCapture];
[picker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
}