Search code examples
objective-cioscore-graphicscalayer

drawing shadow around a view slows down my transition,CALayer,ios


MyViewControllerB.xib contains

view( UIView )
  |
  |__image (UIImageView)
  |
  |__view (UIView)
  |
  |__text (UITextView)
  |
  |__view (UIView) ( shadow is adding at here )

Then I am adding a shadow around the view at the bottom as following

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.bottomView.layer setMasksToBounds:NO];
    self.bottomView.layer.shadowColor   =   [UIColor blackColor].CGColor;
    self.bottomView.layer.shadowRadius  =   5;
    self.bottomView.layer.shadowOpacity =   1;
    self.bottomView.layer.shadowOffset  =   CGSizeMake(0  , 0 );
}

when I am doing pushViewController: animated: at MyViewControllerA :

@implementation MyViewControllerA
    MyViewControllerB  *controller     =   [[MyViewControllerB alloc] initWithNibName:@"MyViewControllerB" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];

Then the transition is not smooth at all. However, if it remove a block of codes used to draw a shadow, the transition is smooth as usual

Do you have any ideas about this issue. Please help if you experienced it before Thanks


Solution

  • Specify the CALayer shadowPath. Apple says, "Specifying an explicit path usually improves rendering performance."