Shadow Orientation UIView Problem

I have a UiTableView within UiView . I want to set corner radius & shadow in a UIView . I use this code to give shadow with corner and its performance.

 myView.backgroundColor = [UIColor clearColor]; [myView.layer setCornerRadius:10.0f]; [myView.layer setBorderColor:[UIColor lightGrayColor].CGColor]; [myView.layer setBorderWidth:1.0f]; [myView.layer setShadowColor:[UIColor blackColor].CGColor]; [myView.layer setShadowOpacity:0.8]; [myView.layer setShadowRadius:3.0]; [myView.layer setShadowOffset:CGSizeMake(2.0, 2.0)]; // below line is for smooth scrolling [myView.layer setShadowPath:[UIBezierPath bezierPathWithRect:myView.bounds].CGPath];` 

everything works fine with Portrait mode . My application is supported as Orientation , and we use the Autoresizing property fot. When I Change Orientation Shadow is displaying according to frame of Portrait mode . How can this be circumvented for orientation.

Any idea how to change setShadowPath to Orientation OR related?

+2
source share
2 answers

I have my own solution. I have one method - (void) viewWithEffects: (UIView*) myView {// copy the shadow code from the question} . Now I called this method - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{} .

So, when the change of orientation didRotateFromInterfaceOrientation will call, and it will give the Corner with Shadow effects. tag Corner with Shadow effects. , the shadow will match your view in accordance with Autoresize your view. if your application is not supported for both orientations, than this does not need to be done. Just call viewdidload or viewwillAppear . Hope this helps.

0
source

Rotating iOS6 Try this code and let me know if it works for you.

  - (BOOL)shouldAutorotate { if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { self.view.backgroundColor = [UIColor redColor]; } else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) { self.view.backgroundColor = [UIColor blackColor]; } return YES; } 
0
source

All Articles