Commit 584e8fda by Daniel Dahan

development: updated TextField rules for Swift 3

parent 55ab6425
...@@ -38,12 +38,13 @@ extension UITabBarItem { ...@@ -38,12 +38,13 @@ extension UITabBarItem {
} }
@IBDesignable @IBDesignable
public class BottomTabBar: UITabBar { open class BottomTabBar: UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview. /// Automatically aligns the BottomNavigationBar to the superview.
public var autoLayoutToSuperview: Bool = true open var isAlignedToParentAutomatically = true
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
@IBInspectable public override var backgroundColor: UIColor? { @IBInspectable
open override var backgroundColor: UIColor? {
didSet { didSet {
barTintColor = backgroundColor barTintColor = backgroundColor
} }
...@@ -70,17 +71,17 @@ public class BottomTabBar: UITabBar { ...@@ -70,17 +71,17 @@ public class BottomTabBar: UITabBar {
prepareView() prepareView()
} }
public override func layoutSublayers(of layer: CALayer) { open override func layoutSublayers(of layer: CALayer) {
super.layoutSublayers(of: layer) super.layoutSublayers(of: layer)
if self.layer == layer { if self.layer == layer {
layoutShape() layoutShape()
} }
} }
public override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
layoutShadowPath() layoutShadowPath()
if let v: Array<UITabBarItem> = items { if let v = items {
for item in v { for item in v {
if .phone == Device.userInterfaceIdiom { if .phone == Device.userInterfaceIdiom {
if nil == item.title { if nil == item.title {
...@@ -90,41 +91,39 @@ public class BottomTabBar: UITabBar { ...@@ -90,41 +91,39 @@ public class BottomTabBar: UITabBar {
let inset: CGFloat = 6 let inset: CGFloat = 6
item.titlePositionAdjustment.vertical = -inset item.titlePositionAdjustment.vertical = -inset
} }
} else { } else if nil == item.title {
if nil == item.title { let inset: CGFloat = 9
let inset: CGFloat = 9 item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0) } else {
} else { let inset: CGFloat = 3
let inset: CGFloat = 3 item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0)
item.imageInsets = UIEdgeInsetsMake(inset, 0, -inset, 0) item.titlePositionAdjustment.vertical = -inset
item.titlePositionAdjustment.vertical = -inset }
}
}
} }
} }
} }
public override func didMoveToSuperview() { open override func didMoveToSuperview() {
super.didMoveToSuperview() super.didMoveToSuperview()
if autoLayoutToSuperview { if isAlignedToParentAutomatically {
if let v: UIView = superview { if let v = superview {
_ = v.layout(self).bottom().horizontally() _ = v.layout(self).bottom().horizontally()
} }
} }
} }
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method it is recommended to override the prepareView method
to initialize property values and other setup operations. to initialize property values and other setup operations.
The super.prepareView method should always be called immediately The super.prepareView method should always be called immediately
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
depthPreset = .depth1 depthPreset = .depth1
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backgroundColor = Color.white backgroundColor = Color.white
let image: UIImage? = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1)) let image = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1))
shadowImage = image shadowImage = image
backgroundImage = image backgroundImage = image
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment