【发布时间】:2016-06-30 15:44:31
【问题描述】:
我想创建一个带有圆角的 UITabBar。有没有办法让 UITabBar 有圆角?它将采用第二张图片的形状。
应用程序从 tableView 开始。当用户点击一个主题时,它们会被发送到一个 tabBar 控制器。
-----编辑-----
这是我的 AppDelegate:
func application(_application: UIApplication,
willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool{
let tabBarController = window?.rootViewController as! UITabBarController
let image = UIImage(named: "bar")
let tabBarImage = resize(image: image!, newWidth: tabBarController.view.frame.width)
tabBarController.tabBar.backgroundImage = tabBarImage
return true
}
func resize(image: UIImage, newWidth: CGFloat) -> UIImage {
UIGraphicsBeginImageContext(CGSize(width: newWidth, height: image.size.height))
image.drawInRect( CGRect(x: 0, y: 0, width: newWidth, height: image.size.height))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage!
}
编辑:21 年 12 月 替换图像以省略项目名称。
【问题讨论】: