美文网首页
更改导航栏背景色以及半透明效果

更改导航栏背景色以及半透明效果

作者: JackMayx | 来源:发表于2016-04-28 15:36 被阅读202次

    直接在

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {}

    这个方法里面加上就可以了

    ///修改导航栏背景颜色和标题文字颜色

    ///导航栏背景色

    let color = UIColor .whiteColor()

    let bar = UINavigationBar.appearance();

    bar.shadowImage = UIImage();

    bar.barStyle = .Default;

    bar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor .blackColor()];

    bar.setBackgroundImage(UIImage(color: color), forBarMetrics: UIBarMetrics.Default);

    bar.translucent = true;

    ///封装方法

    + (UIColor *)colorWithImage:(NSString *)imageNamed{

    return [UIColor colorWithPatternImage:[UIImage imageWithName:imageNamed]];

    }

    + (UIImage *)imageWithName:(NSString *)name{

    NSString *bundlePath = [[NSBundle mainBundle] bundlePath];

    NSString *filePath = [bundlePath stringByAppendingPathComponent:name];

    UIImage *img = [UIImage imageWithContentsOfFile:filePath];

    return img;

    }

    相关文章

      网友评论

          本文标题:更改导航栏背景色以及半透明效果

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