相关疑难解决方法(0)

如何在iOS 7中制作完全透明的导航栏

我希望我的应用程序中的UINavigationBar完全透明,并在其下直接与viewcontroller刷新.但是,我能找到的唯一代码使它半透明但不透明.我知道这可以在iOS 7中完成,因为它在笔记应用程序中使用.我的问题是,他们用来做什么代码?

transparency cocoa-touch uinavigationbar translucency

126
推荐指数
5
解决办法
8万
查看次数

Swift中的透明UINavigationBar

我想让我UINavigationBarUINavigationController透明.我创建了一个子类,UINavigationController并喜欢它在我的storyboard文件中的一个场景.这是我的子类的一部分:

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    let size = self.navigationBar.frame.size
    self.navigationBar.setBackgroundImage(imageWithColor(UIColor.blackColor(), size: size, alpha: 0.2), forBarMetrics: UIBarMetrics.Default)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func imageWithColor(color: UIColor, size: CGSize, alpha: CGFloat) -> UIImage {
    UIGraphicsBeginImageContext(size)
    let currentContext = UIGraphicsGetCurrentContext()
    let fillRect = CGRectMake(0, 0, size.width, size.height)
    CGContextSetFillColorWithColor(currentContext, color.CGColor)
    CGContextSetAlpha(currentContext, alpha)
    CGContextFillRect(currentContext, fillRect)
    let retval: UIImage = …
Run Code Online (Sandbox Code Playgroud)

uinavigationbar ios swift

27
推荐指数
5
解决办法
4万
查看次数