UINavigationBar 下面的 黑线
程序员文章站
2022-06-06 07:56:31
...
iOS开发小结 - UINavigationBar设置shadowImage
let size = self.navigationController!.navigationBar.frame.size
UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.mainScreen().scale)
var context = UIGraphicsGetCurrentContext()
UIColor.blueColor().setFill()
CGContextAddRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, 2))
CGContextDrawPath(context, .Fill)
var image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.navigationController?.navigationBar.shadowImage = image
UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width, size.width+20), false, UIScreen.mainScreen().scale)
context = UIGraphicsGetCurrentContext()
UIColor.redColor().setFill()
CGContextAddRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height+20))
CGContextDrawPath(context, .Fill)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.navigationController?.navigationBar.setBackgroundImage(image, forBarMetrics: .Default)
上一篇: 火药味
下一篇: 人名(名字)最爆笑的精品笑话