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

来源:互联网 发布:算法统宗校释 编辑:程序博客网 时间:2024/04/30 03:23

-(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;
    
}

0 0
原创粉丝点击