类似于QQ个人主页,NavigationBar透明渐变
来源:互联网 发布:淘宝收货时间怎么设置 编辑:程序博客网 时间:2024/05/01 18:42
#import "TableCell.h"
#define SCR_WIDTH [UIScreen mainScreen].bounds.size.width
@interface FMHomeViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong,nonatomic) IBOutletUITableView *mainTableView;
@property (strong,nonatomic) UIImageView *topImgV;
@property (nonatomic,assign) CGFloat alphaMemory;
@end
@implementation FMHomeViewController
static NSString *const Identfier=@"TableCellID";
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
UIView *headerView=[[UIViewalloc] initWithFrame:CGRectMake(0,0, SCR_WIDTH,300)];
headerView.backgroundColor=[UIColorclearColor];
self.mainTableView.tableHeaderView=headerView;
self.topImgV=[[UIImageViewalloc] initWithFrame:CGRectMake(0,0, SCR_WIDTH,300)];
self.topImgV.image=[UIImageimageNamed:@"meinv"];
[self.viewinsertSubview:self.topImgVbelowSubview:self.mainTableView];
self.topImgV.contentMode=UIViewContentModeScaleAspectFill;
self.topImgV.clipsToBounds=YES;
[self.navigationController.navigationBarsetBarTintColor:[UIColorcolorWithRed:37.0/255green:180.0/255blue:237.0/255alpha:1]];
// self.navigationController.navigationBar.hidden=YES;
}
-(void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
[[[self.navigationController.navigationBarsubviews] objectAtIndex:0]setAlpha:_alphaMemory];
if (_alphaMemory ==0) {
self.navigationController.navigationBar.tintColor = [UIColorwhiteColor];
}
else {
self.navigationController.navigationBar.tintColor = [UIColorblackColor];
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return20;
}
-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return60;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TableCell *cell=[tableViewdequeueReusableCellWithIdentifier:IdentfierforIndexPath:indexPath];
return cell;
}
//MARK: tableView delegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"%.f",_mainTableView.contentOffset.y);
CGFloat offsetY = scrollView.contentOffset.y;
CGRect frame=self.topImgV.frame;
if (offsetY>=0) {
frame.origin.y=-offsetY;
//重新赋值 frame
self.topImgV.frame=frame;
if (offsetY<=300) {
self.navigationController.navigationBar.tintColor = [UIColorblackColor];
_alphaMemory = offsetY/(300) >=1 ? 1 : offsetY/(300);
[[[self.navigationController.navigationBarsubviews] objectAtIndex:0]setAlpha:_alphaMemory];
}elseif (offsetY>300){
_alphaMemory =1;
[[[self.navigationController.navigationBarsubviews] objectAtIndex:0]setAlpha:1];
}
}else{
_topImgV.transform = CGAffineTransformMakeScale(1 + offsetY/(-300),1 + offsetY/(-300));
CGRect frame1=self.topImgV.frame;
frame1.origin.y =0;
self.topImgV.frame=frame1;
}
}
- 类似于QQ个人主页,NavigationBar透明渐变
- navigationBar 的渐变透明效果
- navigationBar 透明
- navigationBar 透明
- 实现淘宝和QQ ToolBar透明渐变效果
- 将NavigationBar设置透明
- 将NavigationBar设置透明
- 将NavigationBar设置透明
- IOS-透明NavigationBar
- navigationBar改透明
- iOS navigationBar背景透明
- 将NavigationBar设置透明
- 设置navigationbar透明
- 如何控制navigationbar透明
- 设置透明NavigationBar
- NavigationBar导航栏透明
- iOS NavigationBar设置透明
- navigationBar 设置透明
- 让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法
- 数据结构与算法
- php判断变量是否为数字
- Android Service完全解析,关于服务你所需知道的一切(下)
- 字符串,数组,list集合判断是否为空
- 类似于QQ个人主页,NavigationBar透明渐变
- Matlab random(转)
- 在eclipse中 自定义maven配置
- python内置容器之元组
- H264 RTP 封包原理
- React官方文档--Composition vs Inheritance
- bzoj 2208: [Jsoi2010]连通数 (dfs|tarjan+bitset+拓扑序)
- CentOS7.2下安装VSCode1.6.1后启动失败
- java文件上传和下载