How to add shadow effect for UINavigation panel?

Do you need to add it programmatically? Or is there an option from the main.storyboard interface constructor? And if there is a way from the storyboard, how do you add it?

Something like that: Example

thank

+4
source share
3 answers

You will need to add it programmatically.

Do it in your UINavigationController class

self.navigationBar.shadowColor = UIColor.blackColor().CGColor
self.navigationBar.shadowOffset = CGSizeMake(5, 5)
self.navigationBar.shadowRadius = 5
+1
source

If you want to do this with Storyboard, you need to create an image and install Shadow Image. However, it is easier to do this programmatically in a subclass a UINavigationControlleror in the first view on the stack UINavigationControllerif you just want a very simple shadow effect.

0

self.navigationController.navigationBar.layer.shadowColor = [[UIColor blackColor] CGColor]; self.navigationController.navigationBar.layer.shadowOffset = CGSizeMake (2.0f, 2.0f); self.navigationController.navigationBar.layer.shadowRadius = 4.0f; self.navigationController.navigationBar.layer.shadowOpacity = 1.0f;

-1
source

Source: https://habr.com/ru/post/1655948/


All Articles