如何让他的背景透明化

时间:2012-11-12 12:58:38

标签: iphone objective-c ios uiviewcontroller transparency

我有一个viewcontroller,我在其中模拟一个视图。我有一个firstViewController,我有loginViewController。以下是我在firstViewcontroller上弹出loginViewontroller的代码。

在firstViewController.m中

LoginViewController *login = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:NULL];

        [self presentModalViewController:login animated:YES];

在loginViewController中我有以下功能。

-(void)initialDelayEnded {
    self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    self.view.alpha = 0.0;
    [UIView animateWithDuration:1.0/1.5 animations:^{
        self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    }completion:^(BOOL complete){
        [UIView animateWithDuration:1.0/2 animations:^{
            self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
        }completion:^(BOOL complete){
            [UIView animateWithDuration:1.0/2 animations:^{
                self.view.transform = CGAffineTransformIdentity;
            }];
        }];
    }];

}

在firstViewcontroller中我有一个背景图片。我现在要做的是,loginViewcontroller弹出图像仍然可见。

有人能帮助我吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

您无法通过viewcontroller堆栈查看。最简单的解决方案是将firstviewcontroller中的背景图像传递给第二个并将其设置为背景。

在LoginViewController.h上有一个属性

@property (nonatomic, strong) UIImage* image;

然后在实例化控制器时

LoginViewController *login = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:NULL];
    login.image = self.backgroundImage; //Set the image to the background image
    [self presentModalViewController:login animated:YES];

最后,在loginViewController.m的viewDidLoad

 self.view.backgroundColor = [UIColor colorWithPatternImage:self.image];