2015-11-14 30 views
0

我UITable與細胞:shadowOffset在UITableViewCell中導致緩慢時滾動

enter image description here

,當我在我跌慢表和分片滾動時表重裝

當我刪除陰影代碼,緩慢和碎片消失了。 但我需要陰影。

self.layer.shadowOffset = CGSizeMake(-1,1); 
    self.layer.shadowRadius = 2; 
    self.layer.shadowColor = [[UIColor blackColor] CGColor]; 
    self.layer.shadowOpacity = 0.5; 
+0

試試帶影子感覺的圖像:) – AnshaD

+0

你能解釋一下嗎? –

+0

它只是一個黑客,你可以設置單元格背景圖像的影子 – AnshaD

回答

1

嘗試在圖層屬性上設置shadowPath。指定顯式路徑通常會提高渲染性能。

self.layer.shadowOffset = CGSizeMake(-1,1); 
self.layer.shadowRadius = 2; 
self.layer.shadowColor = [[UIColor blackColor] CGColor]; 
self.layer.shadowOpacity = 0.5; 
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10].CGPath; 

使用self.bounds作爲路徑矩形,確保視圖的框架已經建立。

+0

它的工作,但self.layer.shadowOffset = CGSizeMake(-1,1); 不起作用。 –

+0

@RoeiNadam你的意思'CGSizeMake(-1,1)'不起作用。性能是否提高?影子是否可見?請詳細說明。 – psci