设为首页 加入收藏

TOP

iOS渐变导航栏封装(二)
2019-08-26 07:00:20 】 浏览:53
Tags:iOS 渐变 导航 封装
=@{NSForegroundColorAttributeName: self.notLucencyTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:18]};
    [self setNavigationLeftItemWithImageName:@"more_dark"];
    [self.rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.lightStatusBar = NO;
}

//透明导航栏
-(void)setBackNavDiaphanous
{
    self.navigationController.navigationBar.titleTextAttributes= @{NSForegroundColorAttributeName: self.lucencyTitleColor,NSFontAttributeName:[UIFont systemFontOfSize:18]};
    [self setNavigationLeftItemWithImageName:@"navigationBack"];
     [self.rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.lightStatusBar = YES;
}

 

3.当tableview有组头并且组头要悬浮在导航栏下面,需要做的处理。

 self.contentHeight为tableview的占屏大小,如果contentSize不用滑动就能显示完整,contentInset就不要修改,不然向上滑会有点bug。

 self.offsetChange参数:没组头一般默认64就行,有组头则为组头到顶部的距离

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

 if (self.tableView.contentSize.height >= self.contentHeight) {
        //导航栏渐变处理
        if (offset >= self.offsetChange) {
            self.tableView.contentInset = UIEdgeInsetsMake(KStatusBarAndNavigationBarHeight, 0, 0, 0);
        }else{
            self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        }

     }

}

整体-(void)scrollViewDidScroll:(UIScrollView *)scrollView 方法里面就是做上面三件事啦

 

 做完这些就可以实现渐变了,项目中用的比较多的话直接继承设置一下参数就可以了。

 demon地址:https://github.com/yizhixiafancai/ShadeViewController

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS:WKWebView(19-05-30更) 下一篇iOS在framework中使用CoreData出..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目