繁体   English   中英

如何使他的背景透明

[英]How to make view his background transparent

我有一个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弹出的图像仍然可见。

有谁能够帮助我?

提前致谢。

您看不到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];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM