Commit fb0a00be by Daniel Dahan

development: Fixed issue where image layer was not being respected when modified…

development: Fixed issue where image layer was not being respected when modified by a UIStackView (issue-493).
parent 584e8fda
...@@ -39,7 +39,7 @@ open class Button: UIButton { ...@@ -39,7 +39,7 @@ open class Button: UIButton {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
public private(set) var visualLayer: CAShapeLayer! open private(set) var visualLayer: CAShapeLayer!
/** /**
A base delegate reference used when subclassing View. A base delegate reference used when subclassing View.
...@@ -50,16 +50,19 @@ open class Button: UIButton { ...@@ -50,16 +50,19 @@ open class Button: UIButton {
public private(set) lazy var pulseLayers = [CAShapeLayer]() public private(set) lazy var pulseLayers = [CAShapeLayer]()
/// The opacity value for the pulse animation. /// The opacity value for the pulse animation.
@IBInspectable open var pulseOpacity: CGFloat = 0.25 @IBInspectable
open var pulseOpacity: CGFloat = 0.25
/// The color of the pulse effect. /// The color of the pulse effect.
@IBInspectable open var pulseColor = Color.grey.base @IBInspectable
open var pulseColor = Color.grey.base
/// The type of PulseAnimation. /// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .pointWithBacking public var pulseAnimation: PulseAnimation = .pointWithBacking
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
@IBInspectable open override var backgroundColor: UIColor? { @IBInspectable
open override var backgroundColor: UIColor? {
didSet { didSet {
layer.backgroundColor = backgroundColor?.cgColor layer.backgroundColor = backgroundColor?.cgColor
} }
...@@ -72,6 +75,14 @@ open class Button: UIButton { ...@@ -72,6 +75,14 @@ open class Button: UIButton {
} }
} }
/// Sets the normal and highlighted image for the button.
open var image: UIImage? {
didSet {
setImage(image, for: .normal)
setImage(image, for: .highlighted)
}
}
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
......
...@@ -288,6 +288,10 @@ extension CALayer { ...@@ -288,6 +288,10 @@ extension CALayer {
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
open func layoutShape() { open func layoutShape() {
guard 0 < width, 0 < height else {
return
}
if .none != shapePreset { if .none != shapePreset {
if width < height { if width < height {
frame.size.width = height frame.size.width = height
......
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