tableView等滚动视图滚动时收缩上下导航栏与标签栏
代码如下,今天有点忙,不想细说了,看不明白可以联系我
//
// LQXViewController.m
// LQXCallBackBar
//
// Created by 刘祺旭 on 15/4/27.
// Copyright (c) 2015年 CSDN探花花花. All rights reserved.
// #import "LQXViewController.h"
#define LQXWidth self.view.bounds.size.width
#define LQXHeight self.view.bounds.size.height
#define LQXData [NSString stringWithFormat:@"随机数据---%d", arc4random_uniform(1000000)] @interface LQXViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *dataArray;
@property (nonatomic, assign) BOOL hidden;
@property (nonatomic, assign) BOOL scrollUporDown;
@end @implementation LQXViewController - (void)viewDidLoad {
[super viewDidLoad];
self.tabBarController.tabBar.frame = CGRectMake(0, LQXHeight - 40, LQXWidth, 40);
UIView *statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, LQXWidth, 20)]; statusBarView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"首页--标题栏.png"]]; [self.view addSubview:statusBarView]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, LQXWidth, LQXHeight - 20) style:0];
self.tableView.bounces = YES
;
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.rowHeight = 135;
self.tableView.userInteractionEnabled = YES;
self.tableView.showsHorizontalScrollIndicator = NO;
self.tableView.showsVerticalScrollIndicator = NO;
self.dataArray = [NSMutableArray array];
for (int i = 0; i< 100; i++) {
[self.dataArray addObject:LQXData];
}
[self.view addSubview:self.tableView];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.
return self.dataArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *str = @"reuse";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:str];
}
cell.textLabel.text = self.dataArray[indexPath.row];
return cell; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if ([scrollView isEqual:self.tableView]) {
static float newy = 0;
static float oldy = 0;
newy = scrollView.contentOffset.y ;
if (newy != oldy ) {
if (newy > oldy) {
self.scrollUporDown = YES;
}else if(newy < oldy){
self.scrollUporDown = NO;
}
oldy = newy;
}
if (_scrollUporDown == YES) {
self.hidden = YES;
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.frame = CGRectMake(0, -40, LQXWidth, 40);
self.tabBarController.tabBar.frame = CGRectMake(0 , LQXHeight + 40, LQXWidth, 40);
}]; }
else if (_scrollUporDown == NO) {
if (self.hidden == YES) {
[UIView animateWithDuration:0.5 animations:^{
self.navigationController.navigationBar.frame = CGRectMake(0, 20, LQXWidth, 40);
self.tabBarController.tabBar.frame = CGRectMake(0 , LQXHeight , LQXWidth, 40);
}]; self.hidden = NO;
}
} }
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
tableView等滚动视图滚动时收缩上下导航栏与标签栏的更多相关文章
- [Xcode 实际操作]三、视图控制器-(4)使用UINavigationController导航栏和工具栏
目录:[Swift]Xcode实际操作 本文将演示如何显示和隐藏导航视图的导航栏和工具栏 打开第一个视图控制器 import UIKit class FirstSubViewController: U ...
- React实现顶部固定滑动式导航栏(导航条下拉一定像素时显示原导航栏样式)
摘要 基于react的框架开发一个顶部固定滑动式的酷炫导航栏,当导航栏置顶时,导航栏沉浸在背景图片里:当鼠标滑动滚轮时,导航栏固定滑动并展示下拉样式. JS部分 相关技术栈:react.antd.re ...
- UIScrollView滚动时隐藏底部导航栏问题
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@"開始滚动"); int currentPostio ...
- UIScrollView 滚动视图—IOS开发
转自:http://blog.csdn.net/iukey/article/details/7319314 UIScrollView 类负责所有基于 UIKit 的滚动操作. 一.创建 CGRect ...
- iOS-UIScrollView滚动视图(转)
http://blog.csdn.net/iukey/article/details/7319314 UIScrollView 类负责所有基于 UIKit 的滚动操作. 一.创建 CGRect bou ...
- Android 自学之滚动视图ScrollView
滚动视图ScrollView由FarmeLayout派生而出,他就是一个用于为普通组件添加垂直滚动条的组件:ScrollView里面最多包含一个组件,而ScrollView的作用就是为该组件添加一个垂 ...
- iOS:视图切换的第二种方式:UINavigationController导航栏控制器
UINavigationController:一个以栈的形式管理多视图的容器,负责子控制器之间的跳转.由于以栈的方式管理视图,各个视图的切换就是压栈和出栈操作,所以出栈后的视图会立即销毁. 介绍: & ...
- [Xcode 实际操作]三、视图控制器-(7)UINavigationController自定义导航按钮
目录:[Swift]Xcode实际操作 本文将演示设置导航按钮的样式,以及设置导航标题区域的样式. import UIKit class FirstSubViewController: UIViewC ...
- phpcmsv9如何实现添加栏目时不在首页内容区显示只在导航栏显示
之前王晟璟一直使用PHPCMSV9系统建过自己的个人门户网站,同时也建立了一个其他类型的网站,感觉非常不错,我不得不说PHPCMSV9的功能非常齐全,非常强大. 但有一点时常让王晟璟感到很烦脑,那就是 ...
随机推荐
- 创建zend framework 项目要注意的
1.必须要设置变量环境 我的电脑右击-属性-高级-环境变量 则在环境变量中添加 变量名:PATH 环境值:D:\phpserver\php5.4;D:\ZendFramework\bin 把php.e ...
- c语言scanf详解
函数名: scanf 功 能: 执行格式化输入 用 法: int scanf(char *format[,argument,...]);scanf()函数是通用终端格式化输入函数,它从标准输入设备(键 ...
- publish over ssh
http://stackoverflow.com/questions/22158092/jenkins-transferring-0-files-using-publish-over-ssh-plug ...
- thinkPHP17---操作绑定到类
首先要配置: "ACTION_BIND_CLASS"=>"TRUE"; 控制器类的定义如下: namespace Home\Controller\Inde ...
- hdu_5719_Arrange(脑洞题)
题目连接:hdu_5719_Arrange 题意: 给你1-n这 n个数,设一个排列的第i个数为Ai, Bi为A1到Ai的最小值,Ci为C1到Ci的最大值,问你有多少种排列方式,然后输出取模后的答案 ...
- parseInt(),parseFloat(),parse()
1.parseInt() 该函数将变量转换为整型数.只有对字符串型的数据调用该函数才有意义,其他类型如果使用parseInt()函数,则会返回NaN. 2.parseFloat() 该函数和parse ...
- AngularJS中的$http.post与jQuery.post的区别
原文:http://my.oschina.net/tommyfok/blog/287748 很多时候我们需要用ajax提交post数据,angularjs与jq类似,也有封装好的post. 但是jQu ...
- struts1.x中web.xml文件的配置
1.配置欢迎文件清单 当客户访问Web应用时,如果仅仅给出Web应用的Root URL,没有指定具体的文件名.Web容器会自动调用Web应用的欢迎文件.<welcome-file-li ...
- 有向图强连通分支的Tarjan算法讲解 + HDU 1269 连通图 Tarjan 结题报告
题目很简单就拿着这道题简单说说 有向图强连通分支的Tarjan算法 有向图强连通分支的Tarjan算法伪代码如下:void Tarjan(u) {dfn[u]=low[u]=++index//进行DF ...
- bLock 回调 就是这么简单!
转载自:http://blog.csdn.net/mobanchengshuang/article/details/11751671 我们在开发中常常会用到函数回调,你可以用通知来替代回调,但是大多数 ...