你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS CGPath提升陰影性能

iOS CGPath提升陰影性能

編輯:IOS開發綜合

     發現應用在iTouch4上頁面左右滑動或push進一個視圖控制器時,非常的卡。最後發現時因為給導航控制器的邊框添加了陰影的原因。

                之前的代碼:           


                        - (void)addFrameLeftLine {

                            UIColor *color = [UIColor blackColor];

                            CGSize offset = CGSizeMake(0, 3);

                            float radius = 2;

                            float opacity = 1;

                            self.navigationController.view.layer.shadowColor = color.CGColor;

                            self.navigationController.view.layer.shadowOffset = offset;

                            self.navigationController.view.layer.shadowRadius = radius;

                            self.navigationController.view.layer.shadowOpacity = opacity;

                        }

              修改後的代碼:


                        - (void)addFrameLeftLine {

                            CGPathRef shadow = CGPathCreateWithRect(CGRectInset(self.navigationController.view.bounds, -5, 0), NULL);

                            [self.navigationController.view.layer setShadowPath:shadow];

                            [self.navigationController.view.layer setShadowColor:[[UIColor blackColor] CGColor]];

                            [self.navigationController.view.layer setShadowOpacity:0.3];

                            [self.navigationController.view.layer setShadowRadius:2];

                            CFRelease(shadow);

                        }

 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved