Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply shadow to the navigation bar in swift

Tags:

ios

swift

In my design navigation of app have nice shadow and i want to apply in my code. How to i can create this effect?

enter image description here

like image 600
Sajad Avatar asked Dec 04 '15 17:12

Sajad


People also ask

How do I customize the navigation bar in Swift?

Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.

How do I shadow a button in Swift?

Enter Swift as Language and choose Next. Go to the Storyboard. Add a Button to the main view and give it a title of "Shadow Tutorial". Select the Resolve Auto Layout Issues button and select Reset to Suggested Constraints.


1 Answers

without adding the view

self.navigationController?.navigationBar.layer.masksToBounds = false
self.navigationController?.navigationBar.layer.shadowColor = UIColor.lightGray.cgColor
self.navigationController?.navigationBar.layer.shadowOpacity = 0.8
self.navigationController?.navigationBar.layer.shadowOffset = CGSize(width: 0, height: 2.0)
self.navigationController?.navigationBar.layer.shadowRadius = 2
like image 125
Faruk Duric Avatar answered Sep 21 '22 17:09

Faruk Duric