2013-05-13 2 views
2

이오스에 parallex하는 방법에 대한 튜토리얼 많이 있고 내가 한 here에서 문서를 발견했습니다. 당신이있는 tableview 아래에 삽입 된 이미지를 통해 볼 수 있도록의 시차가 작동하지 않습니다, ios

이 문서의 주요 아이디어는 투명 테이블보기의 헤더를 만드는 것입니다 :

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Create an empty table header view with small bottom border view 
    UIView *tableHeaderView = [[UIView alloc] initWithFrame: CGRectMake(0.0, 0.0, self.view.frame.size.width, 180.0)]; 
    UIView *blackBorderView = [[UIView alloc] initWithFrame: CGRectMake(0.0, 179.0, self.view.frame.size.width, 1.0)]; 
    blackBorderView.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0.8]; 
    [tableHeaderView addSubview: blackBorderView]; 
    [blackBorderView release]; 

    _tableView.tableHeaderView = tableHeaderView; 
    [tableHeaderView release]; 

    // Create the underlying imageview and offset it 
    _headerImageYOffset = -150.0; 
    _headerImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"header-image.png"]]; 
    CGRect headerImageFrame = _headerImage.frame; 
    headerImageFrame.origin.y = _headerImageYOffset; 
    _headerImage.frame = headerImageFrame; 
    [self.view insertSubview: _headerImage belowSubview: _tableView]; 
} 

이 나는 ​​그것을 시도 줄 않았고 그것을 코드가 작동하지 않습니다. 우리가 투명하게 전체 테이블을 만들지 않는 한 투명하게 테이블보기의 머리글을 만들 수는 없다고 생각합니다. 이것에 대해 생각해 본 적이 있습니까? 모든 댓글은 여기에 환영합니다

+0

이 자습서에서는 drawrect 메서드로 뷰를 사용자 정의하는 방법을 보여줍니다. http : //www.raywenderlich.com/32925/core -graphics-tutorial-shadows-and-gloss – Franck

+0

전체 UITableView의 선명한 색상을 사용해 보셨습니까? – iEinstein

+0

Yeh 그 rowboat 샘플도 나를 위해 작동하지 않았다, 나는 방금 내 이미지를 전체 화면 있어요. – malhal

답변

1

나는 그 튜토리얼을 완전히 끝내었고 완벽하게 작동했다. 나는 테이블 배경을 분명하게해야만하는지 기억이 나지 않지만, 명확하게 만드는 것이 무엇이 문제인가? 셀 배경을 원하는 배경색으로 변경하십시오. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

+0

'self.tableView.tableHeaderView.backgroundColor = [UIColor clearColor];를 추가하고 있지만 작동하지 않습니다 .. 내가 얻는 것은 [this] (http://cl.ly/OvS3)와 같습니다. – tranvutuan

+0

테이블을 초기화 한 다음 - (void) tableView : (UITableView *)를 추가하는 self.tableView.backgroundColor = [UIColor clearColor]를 사용해보십시오. tableView willDisplayCell : (UITableViewCell *) cell forRowAtIndexPath : (NSIndexPath *) indexPath {cell.backgroundColor = [UIColor blueColor];} – Augie

+0

아, 지금 당장 받으십시오. 전체적인 생각은 테이블을 투명하게 설정하는 것입니다. 그러면'tableViewHeader'와'cells'도 투명하게 만들 것이고 우리는 그 결과를 볼 수 있도록'contentView' 배경을 변경해야합니다. 그건 속임수 야. 그건 그렇고,'cell.backgroundColor = [UIColor blueColor]'는'cell.contentView.backgroundColor = [UIColor blueColor]'여야합니다. – tranvutuan

4

한번 사용하면 APParallaxHeader 라이브러리와 매력처럼 일했습니다. 나는 당신이 그것을 시도 해달라고 조언한다.)

+0

그래, 나는 통과했다. 그리고 그것은 완벽하게 움직이게되었다. 나는 같은 효과에 대해 다른 기술을 시도하고있다. 그러나 여기에서 달라 붙고있다. – tranvutuan

+0

위대한 작품! 이 링크를 주셔서 감사합니다 !! – sudo

관련 문제