-2

When I run my project, everything seems to be fine but the UIViews Background color still stays solid white when I used this code:

self.view.layer.backgroundColor = [UIColor clearColor];

Don't really no what else to try, I've looked on google and tried some other things but was told this code should do it but no luck.

Mick MacCallum
  • 124,539
  • 40
  • 277
  • 276
redoc01
  • 1,769
  • 5
  • 24
  • 52
  • How about `self.view.backgroundColor = [UIColor clearColor]`? – Linuxios Feb 21 '14 at 17:45
  • @Linuxios, hi, i have tried that also, that didn't work. – redoc01 Feb 21 '14 at 17:46
  • Are you sure that the view behind `self.view` is not just white? What view is behind `self.view`. Is it the window? – Linuxios Feb 21 '14 at 17:47
  • First when the app loads you see a tableview, once you click the cell the Solid white uiview which needs to be transparent is shown with a web view – redoc01 Feb 21 '14 at 17:50
  • @redoc01 do you check the IbOutlet to your View – khaled Feb 21 '14 at 17:50
  • when you click on a cell in the tableview i run this code [self presentModalViewController:youtubeVideoInfoViewController animated:YES]; that opens the UIView that needs the background to be transparent – redoc01 Feb 21 '14 at 17:52
  • layer background should be set to `CGColor` instance, not `UIColor`. Try `[UIColor clearColor].CGColor`. – yurish Feb 21 '14 at 17:53
  • @yurish, nope that cgcolor didn't work – redoc01 Feb 21 '14 at 17:55
  • 1
    This is a view controller's `view` property isn't it? – Mick MacCallum Feb 21 '14 at 17:57
  • @0x7fffffff, hi, I'm new to iPhone development, so please go easy, but yes it is the view controllers property – redoc01 Feb 21 '14 at 17:59
  • @redoc01 See this http://stackoverflow.com/questions/11236367/display-clearcolor-uiviewcontroller-over-uiviewcontroller – Mick MacCallum Feb 21 '14 at 18:01
  • @0x7fffffff, hi, you were right that link helped. But there is another problem i have set self.modalPresentationStyle = UIModalPresentationCurrentContext; in the viewdidload of the tableview controller view, but when the second view controller goes transparent the tableview is not functional – redoc01 Feb 21 '14 at 18:10
  • http://stackoverflow.com/a/1409338/536214 – aqavi_paracha Sep 14 '14 at 09:16
  • Check this [code][1] and [a little correction of the previous][2] here [1]: http://stackoverflow.com/a/1409338/536214 [2]: http://stackoverflow.com/a/3509030/536214 – aqavi_paracha Sep 14 '14 at 09:17

1 Answers1

0

You probably have this kind of code in your app delegate:

  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  self.window.backgroundColor = [UIColor whiteColor];

try chaining the colour from clear to translucent or another colour if it changes then your code for the view background colour is working as it should.

Paulo
  • 1,227
  • 10
  • 8