Answer the question
In order to leave comments, you need to log in
How can two different UITabBars be given different sizes?
How can two different UITabBars be given different sizes using UITabBar.appearance?
According to the existing code, it underlines the same on both TabBars, so where the tabbar is tall, the underline hits almost the center :/
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UITabBar.appearance().selectionIndicatorImage = getImageWithColorPosition(color: UIColor(red:0.94, green:0.33, blue:0.21, alpha:1.0), size: CGSize(width:(self.window?.frame.size.width)!/4,height: 49), lineSize: CGSize(width:(self.window?.frame.size.width)!/4, height:2))
return true
}
func getImageWithColorPosition(color: UIColor, size: CGSize, lineSize: CGSize) -> UIImage {
let rect = CGRect(x:0, y: 0, width: size.width, height: size.height)
let rectLine = CGRect(x:0, y:size.height-lineSize.height,width: lineSize.width,height: lineSize.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
UIColor.clear.setFill()
UIRectFill(rect)
color.setFill()
UIRectFill(rectLine)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
Answer the question
In order to leave comments, you need to log in
appearance proxies parameters for all objects of the class to which the call is applied. You can create UITabBar child classes and use appearance on them, but it's better to just customize the appearance inside these classes.
https://developer.apple.com/documentation/uikit/ui...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question