I am trying to get my tab bar shadow to look like the one seen in this image:
What is the best way of doing thi
Swift 4:
Use This Extension
extension UIImage {
class func colorForNavBar(color: UIColor) -> UIImage {
//let rect = CGRectMake(0.0, 0.0, 1.0, 1.0)
let rect = CGRect(origin: CGPoint(x: 0,y :0), size: CGSize(width: 1.0, height: 1.0))
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context!.setFillColor(color.cgColor)
context!.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
}
Set Shadow Color Using RGB
//Set BackgroundColor
UITabBar.appearance().backgroundImage = UIImage.colorForNavBar(color: .white)
//Set Shadow Color
UITabBar.appearance().shadowImage = UIImage.colorForNavBar(color: UIColor.init(red: 120/255.0, green: 120/255.0, blue: 120/255.0, alpha: 1.0))