2017-05-18 1 views
0

enter image description here표 뷰 내부에서 그림자 만들기

이미지를 사용하고 있지 않다면?

_t.layer.shadowColor = [UIColor blackColor].CGColor; 

    _t.layer.shadowOffset = CGSizeMake(-6, -6); 

    _t.layer.shadowOpacity = 1; 

    _t.clipsToBounds = false; 

외부 그림자가 생길 수 있습니다.

+0

는 상태 표시 줄 또는 탭 표시 줄 아래에 그림자와보기를 추가하고 이러한 뷰는있는 tableView 이상이다. [statusBar - shadowView - tableView] – tomfriwel

답변

1

상태 표시 줄 또는 탭 표시 줄 아래에 그림자가있는보기를 추가하면 이러한보기가 tableView 위에 있습니다.

CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; 
CGFloat tabBarHeight = self.tabBarController.tabBar.bounds.size.height; 

// status bar 
UIView *statusBarShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, statusBarHeight)]; 
statusBarShadowView.backgroundColor = [UIColor whiteColor]; 
[self.view addSubview:statusBarShadowView]; 

CAGradientLayer *gradientLayer0 = [CAGradientLayer layer]; 
gradientLayer0.frame = CGRectMake(0, statusBarHeight, self.view.bounds.size.width, 10); 
gradientLayer0.colors = @[(id)[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:0.7].CGColor, (id)[UIColor colorWithWhite:1 alpha:0.7].CGColor]; 
[statusBarShadowView.layer insertSublayer:gradientLayer0 atIndex:0]; 


// tab bar 
UIView *tabBarShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - tabBarHeight, [UIScreen mainScreen].bounds.size.width, tabBarHeight)]; 
statusBarShadowView.backgroundColor = [UIColor whiteColor]; 
[self.view addSubview:tabBarShadowView]; 

CAGradientLayer *gradientLayer1 = [CAGradientLayer layer]; 
gradientLayer1.frame = CGRectMake(0, -10, self.view.bounds.size.width, 10); 
gradientLayer1.colors = @[(id)[UIColor colorWithWhite:1 alpha:0.7].CGColor, (id)[UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:0.7].CGColor]; 
[tabBarShadowView.layer insertSublayer:gradientLayer1 atIndex:0]; 

+0

tableview의 프레임이 변경되므로 tableview에 추가 할 수 있습니까? –

+0

당신은 할 수 있지만 그림자가 tableview와 함께 스크롤됩니다, 당신은 고정 된 그림자 위치로 어떤 일을 할 것입니다. – tomfriwel

+0

내 말은, 그것은 레이어입니다, 나는 tableview에 놓을 수 있습니다, 그리고 나서 tableview와 함께 움직일 것입니다. –