您的位置:首页 > 移动开发 > IOS开发

iOS 自定义分区头加上图片 以及导航控制器 颜色随滑动改变

2016-06-01 14:28 495 查看
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    if(section==0) {

        return 200;

    }

    

    return 15;

}

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    

    if(section==0) {

        // 自定义第一个 headerView

        UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 200)];

        

        UIImageView* iage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1.png"]];

        iage.frame=view1.frame;

        [view1 addSubview:iage];

        

        return view1;

    }else{

        return nil;

    }

}

// 默认透明 向上滑动时逐渐变色

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {

    self.navigationController.navigationBar.alpha=scrollView.contentOffset.y/200;

    

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: