Reputation: 353
i have developed an iPad app. In that app i have 4 separate views embedded inside a single view controller and there is a navigation bar for each view.I want to set the corner radius of each navigation bar.
i tried
customNavigationBar.layer.cornerRadius = 25;
but this piece of code is not working. Does anyone know how to set the corner radius for each navigation bar.
Upvotes: 8
Views: 11185
Reputation: 12383
Swift 4: Also if you only want the top edges of the navigation bar to have rounded corners, you can try this
override func viewDidAppear(_ animated: Bool) {
self.navigationController?.navigationBar.layer.cornerRadius = 20
self.navigationController?.navigationBar.clipsToBounds = true
self.navigationController?.navigationBar.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
}
Upvotes: 13
Reputation: 293
add quartcore framework and than
in .h file of header
#import <QuartzCore/QuartzCore.h>
and write code as below
self.navigationController.navigationBar.layer.cornerRadius=25;
Upvotes: 1
Reputation: 293
customNavigationBar.layer.cornerRadius=25;
customNavigationBar.clipsToBounds=YES;
i have tested it successfully
Upvotes: 21
Reputation: 936
Add an image with corner rounded as background of navigation bar to make it happen. Check this link Applying rounded corners for the whole application
Upvotes: 2