2012-02-14 5 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; 
} 

편집 : 그것은 바닥 글에있는 UIView를 추가 만의 DropShadow를 생성하지 않습니다. 레이어가 이것에 대한 최선의 접근법인지 또는이 유형의 문제에 대해 올바른지 확실하지 않습니다.

답변

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)와 같습니다.

제로 rect (x = 0, y = 0, width = 0, height = 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);