5

I'm trying to set a shadow on my UISplitViewController's Detail View, that I want to be visible over the Master View, in iOS 6.

In my Detail ViewController:

 self.view.layer.shadowColor = [[UIColor blackColor] CGColor];
 self.view.layer.shadowOffset = CGSizeMake(-3.0f, 0.0f);
 self.view.layer.shadowRadius = 3.0f;
 self.view.layer.shadowOpacity = 1.0f;
 self.view.layer.masksToBounds = NO;
 self.view.clipsToBounds = NO;

However, the SplitVC automatically clips its sub-views, even when I set it to NO in the above code, and there is no shadow.

Can anyone let me know the correct way to achieve this?

3
  • Are you in portrait or landscape orientation ? Oct 17, 2012 at 12:42
  • @tdubik I'm in landscape. I want the shadow to fall on the extreme right of the master view, so that it looks like the detail view is slightly overlapping the master.
    – Arvindh
    Oct 17, 2012 at 13:26
  • I had a similar case, but what was clipping isn't the UISplitViewController, but the UINavigationController that was the in the detail view. The shadow was fine after I navigationController.view.clipsToBounds = false.
    – Diogo T
    Jul 3, 2020 at 22:47

2 Answers 2

1

The best way I found to do this is to add a 1px view to the master view controller and snap it to the right edge and apply a shadow to that view instead.

0

It seems that a superview some way down the hierarchy is performing the clipping.

Try this:

UIView *v = self.view;
do
{
    v.clipsToBounds = NO;
    v = v.superview;
}
while(v != nil);

Be aware that this will turn of clipping for all view in the hierarchy! - This might be more than you asked for:-).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.