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.
customNavigationBar.layer.cornerRadius=25;
customNavigationBar.clipsToBounds=YES;
i have tested it successfully
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]
}
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
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.