0
UITableViewにドロップシャドウを追加するためのサンプルアプリケーションを作成しました。右のナビゲーションボタンをクリックすると、ドロップシャドウがテーブルに追加されます。問題は、影が画面に表示されているテーブルの部分にのみ追加されていることです。上にスクロールして(テーブルから外す)、スクロールして他の人が見えるようにすると、影が見えません。テーブルの高さ全体に影を設定するにはどうすればよいですか?可能であれば、上にスクロールしてテーブルから外れても、シャドウができます(バウンス効果のために)。私は2つのスクリーンショットとコードを添付します。UITableViewへのドロップシャドウの追加が正しく機能しない
最初のスクリーンショットでは、他のセルを表示するためにスクロールし、2番目のスクリーンでは、デフォルトのUITableViewバウンス効果をトリガーするためにスクロールします。
- (void)printIt:(id)sender
{
[self.tableView.layer setShadowColor:[[UIColor orangeColor] CGColor]];
[self.tableView.layer setShadowOffset:CGSizeMake(0, 0)];
[self.tableView.layer setShadowRadius:15.0];
[self.tableView.layer setShadowOpacity:0.8];
[self.tableView.layer setMasksToBounds:NO];
self.tableView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.tableView.layer.bounds].CGPath;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *testButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(printIt:)];
self.navigationItem.rightBarButtonItem = testButton;
[testButton release];
}
#pragma mark UITableView methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 105;
}
ありがとうございます。私はそれについて考えなかった。シンプルで清潔。 –