读文章微信导航栏实现写了demo

Jan 23, 2017

看了这位大哥http://www.jobbole.com/members/3170539585/的文章,关于微信导航栏的实现。
由于他没有给出代码实现,当时我没有设置barstyle,导致不好看,哈哈。
这里给出完整代码
`#import “SHNavigationVC.h”

#import “UIColor+expanded.h”
@interface SHNavigationVC ()
@property (nonatomic, strong) UIView *blurBackView;
@end
@implementation SHNavigationVC

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UINavigationBar navBar = self.navigationBar;
    [navBar insertSubview:self.blurBackView atIndex:0];
    }
    -(UIView
    )blurBackView{
    if (!_blurBackView) {
    _blurBackView = [UIView new];
    _blurBackView.frame = CGRectMake(0, -20, KScreenSize.width, 64);
    CAGradientLayer *gradientLayer = [[CAGradientLayer alloc]init];
    gradientLayer.frame = CGRectMake(0, 0, KScreenSize.width, 64);
    gradientLayer.colors = @[(bridge id)[UIColor colorWithHexString:@”0x040012” andAlpha:0.76].CGColor,(bridge id)[UIColor colorWithHexString:@”0x040012” andAlpha:0.28].CGColor];
    gradientLayer.startPoint = CGPointMake(0, 0);
    gradientLayer.endPoint = CGPointMake(0, 1.0);
    [_blurBackView.layer addSublayer:gradientLayer];
    _blurBackView.userInteractionEnabled = NO;
    _blurBackView.alpha = 0.5;
    }
    return _blurBackView;
    }`