IOS UITabBar selectionIndicatorImage Y position
I have this specification:
But I have this:
I have this code:
self.mTabBar.selectionIndicatorImage = UIImage(named: "footer-blue-line")
How do I set the Y position for selectionIndicatorImage
?
+3
Kevin ABRIOUX
source
to share
3 answers
Why don't you use one "selected" image with a blue line under it?
+1
user3752049
source
to share
http://s18.postimg.org/c5bjg501h/line.png
Use the image in the link in place of the "footer".
0
Pritam
source
to share
Here you go. You just need to set the Tab Bar class for this class in the interface builder
class MyCustomTabBar: UITabBar
{
var didInit = false
override func layoutSubviews()
{
super.layoutSubviews()
if didInit == false
{
didInit = true
for subview in subviews {
// can't hookup to subviews, so do layer.sublayers
subview.layer.addObserver(self, forKeyPath: "sublayers", options: .New, context: nil)
}
}
}
deinit
{
for subview in subviews
{
subview.layer.removeObserver(self, forKeyPath: "sublayers")
}
}
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>)
{
// layer.delegate is usually the parent view
if let l = object as? CALayer, tbButton = l.delegate as? UIView where tbButton.window != nil
{
for v in tbButton.subviews
{
if String(v.dynamicType) == "UITabBarSelectionIndicatorView" {
v.setYOrigin(3)
}
}
}
}
}
0
Dannie P
source
to share