是否可以制作完全自定义的UIImagePickerController?

时间:2014-11-11 15:43:06

标签: ios objective-c xcode uinavigationcontroller uiimagepickercontroller

好的,我有一个UIImagePickerControler。我希望它是全屏的,我想要一个我可以完全自定义的导航控制器。这可能吗?我尝试制作自己的UINavigationController并推出隐藏了导航栏和相机全屏的UIImagePickerController,但显然Apple不允许这样做。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

是的,在这里你是我的一个:

   #pragma mark - Custom ImagePicker
   -(void) createCustonImagePicker
  {

self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePickerController.showsCameraControls = NO;



CGFloat height = [UIScreen mainScreen].bounds.size.height;
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,      self.imagePickerController.view.bounds.size.width, self.imagePickerController.view.bounds.size.height)];
UIView *downBack;

if (height == 480) {
    // Configure to iPhone 4 -4s
    UIView *upBack = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 35)];
    upBack.backgroundColor = [UIColor blackColor];
    [newView addSubview:upBack];
    downBack = [[UIView alloc] initWithFrame:CGRectMake(0, 355, 320, 125)];
    downBack.backgroundColor = [UIColor blackColor];
    [newView addSubview:downBack];

    UIButton *flashButton = [[ UIButton alloc] initWithFrame:CGRectMake(15, 7, 120, 20)];
    // Configure your own flash button
    [upBack addSubview:flashButton];

    UIImageView *icono = [[UIImageView alloc] initWithFrame:CGRectMake(5, 12, 22, 22)];
    icono.image = [UIImage imageNamed:@"dotred"];
    [downBack addSubview:icono];

    UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(40, 2.5, 280, 40)];
    text.font = // Here your font;
    text.textColor = [UIColor whiteColor];
    text.text = NSLocalizedString(@"Here is and example to see", nil);
    text.numberOfLines = 2;
    [downBack addSubview:text];

    UIButton *cancel = [[UIButton alloc] initWithFrame:CGRectMake(230, 7, 70, 20)];
    // cancel.titleLabel.font = MAIN_FONT;
    cancel.titleLabel.textAlignment = NSTextAlignmentRight;
    cancel.titleLabel.textColor = [UIColor whiteColor];
    [cancel setTitle:NSLocalizedString(@"Cancel", nil) forState:UIControlStateNormal];
    [cancel addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
    [newView addSubview:cancel];


} else {
    UIView *upBack = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 80)];
    upBack.backgroundColor = [UIColor blackColor];
    [newView addSubview:upBack];
    downBack = [[UIView alloc] initWithFrame:CGRectMake(0, 400, 320, 168)];
    downBack.backgroundColor = [UIColor blackColor];
    [newView addSubview:downBack];

    UIButton *flashButton = [[ UIButton alloc] initWithFrame:CGRectMake(15, 27, 120, 20)];

    [upBack addSubview:flashButton];

    UIImageView *icono = [[UIImageView alloc] initWithFrame:CGRectMake(10, 22, 22, 22)];
    icono.image = [UIImage imageNamed:@"dotred"];
    [downBack addSubview:icono];

    UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(40, 12.5, 280, 40)];
    text.font =You font;
    text.textColor = [UIColor whiteColor];
    text.text = NSLocalizedString(@"Example the\ntext, nil);
    text.numberOfLines = 2;
    [downBack addSubview:text];

    UIButton *cancel = [[UIButton alloc] initWithFrame:CGRectMake(230, 27, 70, 20)];
    // cancel.titleLabel.font = MAIN_FONT;
    cancel.titleLabel.textColor = [UIColor whiteColor];
            cancel.titleLabel.textAlignment = NSTextAlignmentRight;
    [cancel setTitle:NSLocalizedString(@"Cancel", nil) forState:UIControlStateNormal];
    [cancel addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
    [newView addSubview:cancel];
}


   self.takePhotoButton = [[UIButton alloc] initWithFrame:CGRectMake(123, height -80, 73, 73)];
   [self.takePhotoButton setImage:[UIImage imageNamed:@"cambuttonred"] forState:UIControlStateNormal];
    [self.takePhotoButton setImage:[UIImage imageNamed:@"cambuttonblack"] forState:UIControlStateHighlighted];
   [newView addSubview:self.takePhotoButton];
    [self.takePhotoButton addTarget:self action:@selector(takeTakMainPhoto) forControlEvents:UIControlEventTouchUpInside];
   self.takePhotoButton.hidden = YES;

[newView addSubview:self.isReadyLabel];
self.imagePickerController.cameraOverlayView = newView;
if (height == 480) {
self.imagePickerController.cameraViewTransform = CGAffineTransformMake(1.0, 0.0, 0.0,1.0, 0.0, 35);
} else {
self.imagePickerController.cameraViewTransform = CGAffineTransformMake(1.0, 0.0, 0.0,1.0, 0.0, 80);
}

self.imagePickerController.delegate = self;



 }