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;
}
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;
}
相关文章推荐
- 正确使用iOS常量(const)、enum以及宏(#define)
- iOS 相机拍照声音消失方法
- iOS 获取今年指定月的天数
- iOS 使用CocoaPods过程中的几个问题
- GCD队列组
- 禁止 iOS 浏览器 自动识别拨号
- ios性能测试Instruments
- iOS 在已有项目添加CoreData
- 了解一下ffmpeg
- Xcode真机调试bug集(有待更新)
- iOS测试使用的ipa包快速打包方法
- OC - 使用GCD实现倒计时功能
- iOS - xcode7 免证书真机调试
- iOS使用自定义字体
- iOS -- 常用第三方框架
- IOS CoreAnimation中layer动画闪烁的解决方法
- iOS 自定义textField 显示下划线 左边显示文字 自定义placeholder的颜色和字体
- iOS 7滑动返回那些事儿
- iOS 字符串通过特定字符转变成数组
- 设置git提交忽略文件