2014-09-04 92 views
1

命名VC新的UIViewController例如,然后调用呈现控制器具有α为0.5

[self presentViewController:vc animated:YES completion:nil];

我想VC看起来像透明或α= 0.5,

我知道下面的代码可以做到这一点,埠目前的动画消失,我想透明annimation,任何想法?

self.modalPresentationStyle = UIModalPresentationCurrentContext;

+0

小心动画新意见,如果他们不不透明 - 有时使用iOS版不透明度来隐藏其内置的动画的工作,并引入半透明可以看看真的不好。 – Echelon 2014-09-04 09:57:26

回答

1

我不知道这是最好的解决办法,但你绝对可以做自己的动画很简单:

NewViewController *newVC = [[NewViewController alloc] init]; 
newVC.view.frame = CGRectMake(0, SCREEN_HEIGHT, self.view.frame.size.width, self.view.frame.size.height); 
newVC.view.alpha = 0.5;  

[self addChildViewController:newVC]; 
[self.view addSubview:newVC.view]; 

[UIView animateWithDuration:0.3 animations:^{ 
    newVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 
} completion:nil]; 
1

如果你给不透明度查看,所有的按钮,标签等也将具有不透明性。

按照下面为你想要什么步骤...

,得透明的颜色来查看。

self.view.backgroundColor = [UIColor clearColor]; 

然后添加的UIImageView和得到背景颜色为透明的颜色,然后说的不透明度为0.5。

myImage.backgroundColor = [UIColor clearColor]; 
myImage.alpha = 0.5; 
+0

我希望呈现的ViewController看起来透明,而不是当前的ViewController。 – Mil0R3 2014-09-04 14:21:32

+0

@Geaka:好的,然后使用'yourView.backgroundColor' – 2014-09-04 20:13:41