2012-02-14 10 views
1

私はわずか数行のテーブルビューを持っています。だからブランクの束を表示するのではなく、空のUIViewをtableview.footerに追加しました。しかし、私はUIViewにドロップシャドウをキャストする最後のセルが欲しいです。どうすればこれを達成できますか?ここに私の現在のコードです。iOS:表のセルのフッターのドロップシャドウ

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    UIView *emptyView = [[UIView alloc] initWithFrame:CGRectZero]; 
    CALayer *layer = [emptyView layer]; 
    [layer setShadowOffset:CGSizeMake(0, 1)]; 
    [layer setShadowColor:[[UIColor darkGrayColor] CGColor]]; 
    [layer setShadowRadius:8.0]; 
    [layer setShadowOpacity:0.8]; 
    self.tableView.tableFooterView = emptyView; 
} 

EDIT: それはフッターにUIViewのを追加することなく、ドロップシャドウを作成されていません。私は層がこれのための最善のアプローチであるか、このタイプのものに対して正しいと確信していません。

答えて

0

は私がcellForRowAtIndexPath:機能で

shadowBackgroundView.layer.shadowOpacity = 0.3; 
shadowBackgroundView.layer.shadowRadius = 2; 
shadowBackgroundView.layer.shadowColor = [[UIColor blackColor] CGColor]; 
shadowBackgroundView.layer.shadowOffset = CGSizeMake(0.0, 1.0); 
CGPathRef shadowPath = [UIBezierPath bezierPathWithRoundedRect: shadowBackgroundView.bounds 
                 byRoundingCorners: UIRectCornerAllCorners 
                   cornerRadii: CGSizeMake(PageCellBackgroundRadius, PageCellBackgroundRadius)].CGPath; 
shadowBackgroundView.layer.shadowPath = shadowPath; 
shadowBackgroundView.layer.shouldRasterize = YES; 

[self addSubview: shadowBackgroundView]; 
0

フレームをCGRectZeroに設定している可能性があります。

ゼロの四角形は、CGRectMake(0,0,0,0)に相当します。

ゼロ矩形(x = 0、y = 0、幅= 0、高さ= 0)の影はまったく表示されません。

適切なフレームサイズを指定してみてください。違いがわかります。同様に参照のために、このうち

チェック:https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGGeometry/Reference/reference.html

+0

'CGRectMakeとはまったく違い(0,0,100,100 ) ' – Bot

0

を使用して終了:

// drop shadow 
cell.layer.shadowOpacity = 1.0; 
cell.layer.shadowRadius = 1.7; 
cell.layer.shadowColor = [UIColor blackColor].CGColor; 
cell.layer.shadowOffset = CGSizeMake(0.0, 0.0); 
関連する問題