我正在將shadows
添加到UITableView
的單個單元格中。在這個意義上陰影不一致,請考慮以下情況:UITableView中的陰影不一致
有20行顯示,最初,在第一個視圖中只有10行是可見的。這裏陰影可以正常顯示。但是,只要我向下滾動/向上滾動,現在可見的一些新細胞正在按預期顯示陰影,而其他細胞卻沒有。問題看起來與UITableViewCell
的layer
的zPosition
。對於一些細胞來說,陰影在後面,而對於其他細胞而言,它與前面的細胞相比處於前面,這使得用戶可以看見/不可見。因爲我遇到的大多數帖子(例如Objective C: How to add Shadow effect to navigation bar and table cells)都沒有明確設置UITableViewCell
的圖層zPosition,所以我想知道這是必需的還是我在這裏丟失的東西。
編輯:請找到代碼片段在這裏
-(UITableViewCell*)tableView:(UITableView*) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
navigatorCell* cell = (navigatorCell *)[tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"] forIndexPath:indexPath];
// cell configuration code goes here
//now add shadow
[cell.layer setMasksToBounds:NO];
cell.layer.shadowColor = [[UIColor blackColor] CGColor];
cell.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
cell.layer.shadowRadius = 3.0f;
cell.layer.shadowOpacity = 0.750f;
cell.clipsToBounds = NO;
//if I uncomment this, then it works properly, but problem arises again if I insert/remove cells
// cell.layer.zPosition = -indexpath.row;
CGRect shadowFrame = cell.layer.bounds;
CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:shadowFrame].CGpath;
cell.layer.shadowPath = shadowPath;
return cell;
}
你能後的截圖...... – Venkat 2013-03-18 12:16:05
能否請您加入你的代碼。沒有代碼我不能做任何事情 – 2013-03-18 12:18:04
請求者找到上面的代碼。 – Yadvendar 2013-03-18 12:35:19