Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let tabbar = self.tabBarController?.tabBar
- tabbar?.selectionIndicatorImage = UIImage().createSelectionIndicator(color: bColor, size: CGSize(width: (tabbar?.items![0].selectedImage?.size.width)!, height: (tabbar?.frame.height)!), lineWidth: 2.0)
- extension UIImage
- {
- func createSelectionIndicator(color: UIColor, size: CGSize, lineWidth: CGFloat) -> UIImage
- {
- UIGraphicsBeginImageContextWithOptions(size, false, 0)
- color.setFill()
- var yFloatValue: CGFloat
- if size.height < 80
- {
- yFloatValue = (size.height * 0.90 - lineWidth)
- }
- else
- {
- yFloatValue = (size.height * 0.55 - lineWidth)
- }
- UIRectFill(CGRect(x: 0, y: yFloatValue, width: size.width, height: lineWidth))
- let image = UIGraphicsGetImageFromCurrentImageContext()
- UIGraphicsEndImageContext()
- return image!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement