1

数行しかないテーブルビューがあります。そのため、空白の束を表示する代わりに、tableview.footerに空白のUIViewを追加しました。ただし、最後のセルでUIViewにドロップシャドウをキャストしたいと思います。どうすればこれを達成できますか?これが私の現在のコードです。

- (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;
}

編集:UIViewをフッターに追加していますが、ドロップシャドウは作成していません。レイヤーがこれに最適なアプローチであるか、このタイプのものに適しているかはわかりません。

4

3 に答える 3

0

フレームをCGRectZeroに設定したことが原因と考えられます。

ゼロの長方形は、CGRectMake(0,0,0,0)と同等です。

ゼロレクティ(x = 0、y = 0、width = 0、height = 0)のシャドウはまったく表示されません。

適切なフレームサイズを指定してみてください。違いがわかります。

参照についてもこれをチェックしてください:https ://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGGeometry/Reference/reference.html

于 2012-02-14T22:47:11.610 に答える
0

私は使用することになった

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];
于 2012-10-24T18:35:16.203 に答える
0

機能中cellForRowAtIndexPath:

// 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);
于 2014-10-26T04:06:21.177 に答える