关于导航栏透明和渐变的一些设置

   都是网上找的自己整理一下

   //背景色

    [[UINavigationBar appearance] setBarTintColor:UIColorWithRGBA(117, 210, 185, 1)];

    //title的颜色

    [[UINavigationBar appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

    //返回按钮的颜色

    [[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];


    //返回按钮不带文字

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

    //下面两个方法会让导航栏透明

    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

    

    self.navigationController.navigationBar.shadowImage = [UIImage new];



    barImageView  = self.navigationController.navigationBar.subviews.firstObject

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

        //导航栏的颜色

        barImageView.alpha = _tableView.contentOffset.y / 100;

        //中间文字的颜色

        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor           colorWithRed:_tableView.contentOffset.y/100 green:_tableView.contentOffset.y/100 blue:_tableView.contentOffset.y/100 alpha:1]};

        //右边按钮的颜色

        [self.rightBtn setTitleColor:[UIColor colorWithRed:_tableView.contentOffset.y/100 green:_tableView.contentOffset.y/100 blue:_tableView.contentOffset.y/100 alpha:1] forState:UIControlStateNormal];

}


注意:

在push到下一个界面的时候让tableView或者scrollView的delegate = nil,再将

 barImageView.backgroundColor =UIColorWithRGBA(117, 210, 185, 1);

    barImageView.alpha = 1;

设置回来

在viewwillappear中又将代理设置回来。谨记!!!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值