방사형 그라데이션 배경을 가진 ViewController가 있습니다. 그 안에는 셀과 섹션이있는 UITableView가 있습니다. 이제 스크롤 할 때 테이블보기 뒤에 그라디언트를 표시하고 싶습니다. 문제는 섹션이 상단에 잠겨 있으면 섹션 뒤에있는 셀을 볼 수 있다는 것입니다. 섹션 배경색을 설정 하겠지만 그래도 방사형 그라디언트 배경과 일치하지 않습니다. 어쨌든 clearColor 배경을 유지하면서 섹션 아래에 셀 클립이 있습니까?clearColor 배경을 가진 UITableView 섹션?
답변
내가 이해한다면, 당신은보기 컨트롤러의 배경을 볼 수 있도록 테이블 뷰와 테이블 뷰 셀을 완벽하게 원한다.
당신은 당신이 또한 섹션을 투명하게하려면, 당신은이 방법을 사용할 수 있습니다
cell.backgroundColor = [UIColor clearColor]
어떤 배경
tableview.backgroundColor = [UIColor clearColor];
tableView.opaque = NO;
tableView.backgroundView = nil;
또한 세포가없는 것처럼있는 tableview를 설정하여이를 달성 할 수있다 :
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
사용자 정의보기 만들기 (예 : transparen t.png 배경)
나는 당신의 질문을 올바르게 이해할 수 있기를 바랍니다.
:이 바르와 jQuery과의 하위 클래스 인 클래스를 만들 : 설명 후
이편집
은 세포 섹션 헤더 아래에 가기 전에 중지하는 것이 모양을 제공하는
@interface CustomTableView : UITableView
{
CAGradientLayer* maskLayer;
}
분명히 이것은 그라디언트를 만들지 만 원하는 경우 조정할 수도 있고을 사용할 수도 있습니다및 프로그래밍 방식으로 마스크를 만드는 대신 구역 머리글의 너비/높이가 올바른 .png를 만듭니다. 어쨌든
: 당신이 사용하는 경우 CAGradientLayer
:
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
[self setupGradients]; //call your method
}
return self;
}
- (void)setupGradients
{
[self addObserver:self forKeyPath:@"contentOffset" options:0 context:nil];
*/ ***** if you choose to use CALayer instead of CAGradient ****** */
//maskLayer = [[CALayer layer] retain];
//maskLayer.contents = (id) [UIImage imageNamed:@"maskLayer.png"].CGImage;
//maskLayer.backgroundColor = [UIColor clearColor].CGColor;
*/ ***** if you choose to use CALayer instead of CAGradient ****** */
maskLayer = [[CAGradientLayer layer] retain];
CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
maskLayer.colors = [NSArray arrayWithObjects:(id)outerColor,
(id)innerColor, (id)innerColor, (id)outerColor, nil];
maskLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.9],
[NSNumber numberWithFloat:1.0], nil]; //this creates a gradient effect. Tweak these numbers for a hard line.
maskLayer.bounds = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
maskLayer.anchorPoint = CGPointZero;
self.layer.mask = maskLayer;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
[CATransaction begin];
[CATransaction setDisableActions:YES];
maskLayer.position = CGPointMake(0, self.contentOffset.y);
[CATransaction commit];
}
:
이CustomTableView *_tableView; //ivar
_tableView = [[CustomTableView alloc] initWithFrame:YOUR_FRAME];
는 기본적인 아이디어는, 당신이 당신의 tableview의 상단에 마스크 모양을 마스크 생성한다 섹션 헤더와 크기가 같습니다. 그것 뒤에 세포가 "사라"나타납니다. 조금 까다 롭지 만 작동 할 것입니다.
당신은 내가 성취하려고 노력하고있는 것이지만 내가 갖고있는 문제는 이해하지 못하고 있습니다. 문제는 내 섹션이 투명 해 섹션을 지나갈 때 셀을 볼 수 있다는 것입니다. 이것은 끔찍한 셀과 섹션의 혼합을 만듭니다. 그래도 대답을 고맙다, – Bobbake4
아, 지금은 이해합니다. 재미있는 질문. 어떻게 할 수 있는지에 대한 아이디어가 있지만 조금 해킹 된 것 같습니다. 위의 내 대답을 편집합니다. – sixstatesaway
헤더보기를 직접 생성하지 않고도 투명 섹션 헤더를 얻는 간단한 방법입니다.
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) {
UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView *)view;
headerView.contentView.backgroundColor = [UIColor clearColor];
headerView.backgroundView.backgroundColor = [UIColor clearColor];
}
}
코드의이 작품은 아이폰 OS에 완벽하게 잘 작동 7.
편집 나는이 조금 늦게, 그러나이와 함께 당신은 배경 색상을 확인하는 두 줄을 추가해야 알 (배경보기의 배경색?)도 분명합니다.
tableView.backgroundColor = [UIColor clearColor];
tableView.backgroundView.backgroundColor = [UIColor clearColor];
완벽한! 그것은 나를 위해 일했다. 대단히 감사합니다. –
- 1. UITableView 섹션 배경?
- 2. UITableView 섹션 색인
- 3. 투명한 배경을 가진 MPMoviePlayerViewController를로드 중입니까?
- 4. UITableView 섹션 헤더 iOS 5
- 5. UITableView 섹션 제목의 색을 바꿉니다.
- 6. UITableView 섹션 관련 문제
- 7. UITableView : 섹션 컨트롤을 삭제하십시오.
- 8. UITableview 섹션 문제
- 9. UITableView 섹션 주위의 그림자
- 10. UITableView 섹션 인덱싱
- 11. 다중 섹션 UITableView 문제
- 12. UITableview 섹션 오류 - objc_msgSend
- 13. UITableView 섹션 머리글 스크롤
- 14. UITableView : 앵커 섹션 헤더
- 15. UITableView : 섹션 식별자 문제
- 16. NSFetchedResultsController 및 UITableView 섹션
- 17. 동적 UITableView 섹션 계산을위한 공식
- 18. 투명한 배경을 가진 UIViewAnimationTransitionCurlUp
- 19. UITableView 재주문은 배경을 숨 깁니다.
- 20. 내가 UITableView 배경을 바꿀 때 셀이 사라집니다.
- 21. 정적 셀이있는 UITableView - 섹션 당 구분 색상이 다릅니 까?
- 22. 셀이 UITableView 섹션 너비를 채우게하십시오.
- 23. UITableView 섹션 헤더의 색 변경
- 24. 편집 할 수없는 UITableView 섹션?
- 25. NSDictionary 개체의 UITableView 섹션 구현
- 26. iPhone UITableView 중첩 된 섹션
- 27. 제목으로 UITableView 섹션 제목 배경색
- 28. 편집 모드의 UITableView 섹션 헤더
- 29. 사이드 섹션 헤더 이미지가있는 UITableView
- 30. 섹션 헤더가없는 인덱싱 된 UITableView
스크린 샷을 게시 할 수 있습니까? 이것을 시각화하는 데 어려움이 있습니다. –
tableview.backgroundColor = [UIColor clearColor]를 설정할 수 있습니다. – kamleshwar