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的功能非常齐全,非常强大. 但有一点时常让王晟璟感到很烦脑,那就是 ...
随机推荐
- 【二分图】 poj 1466
#include <iostream> #include <memory.h> #include <cstdio> using namespace std; int ...
- 用ifconfig命令,只有lo,没有eth0的解决方案
解决方案: 1. 进入/etc/sysconfig/network-scripts 目录,发现有ifcfg-eth0,即网卡(驱动)存在但未启用. 2. 输入ifconfig -a命令,可显示eth0 ...
- Swift\本地文件管理
转载自:http://www.coloroud.com/2015/06/01/Swift-File-Manager/ 开头 看来Swift这趟浑水是非干不可,既然如此,那索性就来的彻底吧,来一次全方位 ...
- instanceof实例和prototype
var arr=[1,3,2];alert(arr instanceof Array); 返回true: 对于继承譬如一个Drag()拖拽的继承,我想加一个限制范围的拖拽 我需要写一个新的函数 fun ...
- HDU 1681 Frobenius(完全背包+标记装满)
一个完全背包,数组两百万,暴力可过 #include<iostream> #include<cstdio> #include<cstring> using name ...
- android 报错之noclassdeffounderror
解决方案1: 导入第3方jar包问题,明明导入了jar但还是报java.lang.NoClassDefFoundError解决步骤:1.在Android项目根目录下新建一个lib文件夹:2.把你需要导 ...
- Java的SSH框架
SSH 为 struts+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架. 1.业务流程 集成SSH框架的系统从职责上分为四层:表示层.业务逻辑层.数据 ...
- 注意:MainActivity的oncreate方法里不要再inflate布局了(MainActivity里的点击事件无响应)
activity_main已经通过setContentView(R.layout.activity_main);设置给MainActivity, 不要再inflate出新布局,然后findviewby ...
- 表达式语言--在MVC中应用表达式语言
之前讲解的MVC设计模式中一直有DAO存在,而且所有的对象都保存在VO之中,那么这时如果将一个VO传递到JSP文件中,那么JSP需要导入VO包,如果使用表达式语言的话,导入VO包就没有任何意义了. V ...
- PHP使用Redis
首先确保安装了Redis扩展 详细的使用方式 请浏览扩展文档 https://github.com/phpredis/phpredis#connection $obj = new Redis(); $ ...