Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Getting desired shadow above UITabBar

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 this? I am using objective-c
Thanks

like image 777
rohinb Avatar asked May 20 '16 05:05

rohinb


2 Answers

You can give shadow by using following code to any UI object

tabBar.layer.shadowOffset = CGSize(width: 0, height: 0)
tabBar.layer.shadowRadius = 2
tabBar.layer.shadowColor = UIColor.black.cgColor
tabBar.layer.shadowOpacity = 0.3

Here i gave example for your tabControl object.

like image 145
Shreyank Avatar answered Nov 14 '22 13:11

Shreyank


For Swift 5 :

tabBar.layer.shadowOffset = CGSize(width: 0, height: 0)
tabBar.layer.shadowRadius = 2
tabBar.layer.shadowColor = UIColor.black.cgColor
tabBar.layer.shadowOpacity = 0.3
like image 14
Hamid Reza Ansari Avatar answered Nov 14 '22 14:11

Hamid Reza Ansari