ios 7 - transparency in IB not working correctly? setting transparency programmatically also isn't working?

允我心安 提交于 2019-12-11 08:55:37

问题


I have created two UIViewControllers in IB.

PROBLEM 1: I can't make the 2. VC transparent. I have read a lot of stackOverFlow solutions but nothing seems to work in my case. I have tried the following setup in IB both in my current project and in this simple project and something strange occurs (IB,for 2.VC):

  1. Setting the alpha value below 0,5
  2. Setting opaque to "checked"
  3. Setting the background color to "black"

https://imageshack.com/i/kqdXWk9Jp

The second VC gets pushed when I click "GO TO NEXT VC" (push or modally , doesn't matter) and while he is being pushed I see the the result I want:

https://imageshack.com/i/idXUCFCPp

... and when the push is finished the new VC changes from being transparent to black (not transparent):

https://imageshack.com/i/iqmLw8D1p

I have no clue why this is happening and I cant get it to stop working like that. Q1: Why is this happening?

Q2: Why can't I change the properties of the views programmatically when the views are created with IB? I have done this thousand times WITHOUT using IB. As soon as I start using IB things don't work like they are supposed especially when I try to edit stuff programmatically. When I do all of these steps without IB only in code everything works perfectly fine but I need to use the IB in my next project. I am using Xcode 5.1.1. on mac mini (late 2009) with Mavericks.


回答1:


Sorry for bad English.

Your problem is because the memory management of iOS removes the previous interface ViewController, to save resources.

After iOS7, you can customize the transition viewControllers. Please read: UIViewControllerAnimatedTransitioning Protocol Reference.

I also had the same problem and managed to solve it by following the tutorial Custom UIViewController Transitions.

If you are still having doubts, there is another tutorial to help you: iOS7: Custom Transitions.

Hope you get success!



来源:https://stackoverflow.com/questions/25259777/ios-7-transparency-in-ib-not-working-correctly-setting-transparency-programma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!