美文网首页
ios 导航栏问题--渐变色

ios 导航栏问题--渐变色

作者: 有缘人2830 | 来源:发表于2018-11-05 11:27 被阅读22次

    pragma mark -- 修改导航栏渐变色 colorWithAlphaComponent防止污染子控件透明度

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
       CGFloat alpha = scrollView.contentOffset.y/100;
       if (alpha > 1) {
           alpha = 1;
       }else if (alpha<0){
           UIColor *color = [UIColor colorWithHexString:@"#ff8833"];
           self.navigationBar.backgroundColor = [color colorWithAlphaComponent:-alpha];
       }else{
           UIColor *color = [UIColor colorWithHexString:@"#ff8833"];
           self.navigationBar.backgroundColor = [color colorWithAlphaComponent:alpha];
       }
    }
    

    相关文章

      网友评论

          本文标题:ios 导航栏问题--渐变色

          本文链接:https://www.haomeiwen.com/subject/jszjxqtx.html