From 619511c39c0c3abddf66065fcf38e7f0f8384a8b Mon Sep 17 00:00:00 2001 From: Leeroy Ding Date: Tue, 27 Oct 2015 21:18:01 +0000 Subject: [PATCH 1/3] Add IBDesignable and IBInspectable --- GradientView/GradientView.swift | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/GradientView/GradientView.swift b/GradientView/GradientView.swift index 5cb7c42..38feae6 100644 --- a/GradientView/GradientView.swift +++ b/GradientView/GradientView.swift @@ -9,12 +9,13 @@ import UIKit /// Simple view for drawing gradients and borders. +@IBDesignable public class GradientView: UIView { // MARK: - Types /// The mode of the gradient. - public enum Type { + public enum Type { /// A linear gradient. case Linear @@ -56,7 +57,7 @@ public class GradientView: UIView { /// Automatically dim gradient colors when prompted by the system (i.e. when an alert is shown). /// - /// The default is `true`. + /// The default is `true`. public var automaticallyDims: Bool = true /// An optional array of `CGFloat`s defining the location of each gradient stop. @@ -71,49 +72,56 @@ public class GradientView: UIView { } } - /// The mode of the gradient. The default is `.Linear`. + /// The mode of the gradient. The default is `.Linear`. + @IBInspectable public var mode: Type = .Linear { didSet { setNeedsDisplay() } } - /// The direction of the gradient. Only valid for the `Mode.Linear` mode. The default is `.Vertical`. + /// The direction of the gradient. Only valid for the `Mode.Linear` mode. The default is `.Vertical`. + @IBInspectable public var direction: Direction = .Vertical { didSet { setNeedsDisplay() } } - /// 1px borders will be drawn instead of 1pt borders. The default is `true`. + /// 1px borders will be drawn instead of 1pt borders. The default is `true`. + @IBInspectable public var drawsThinBorders: Bool = true { didSet { setNeedsDisplay() } } - /// The top border color. The default is `nil`. + /// The top border color. The default is `nil`. + @IBInspectable public var topBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The right border color. The default is `nil`. + /// The right border color. The default is `nil`. + @IBInspectable public var rightBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The bottom border color. The default is `nil`. + /// The bottom border color. The default is `nil`. + @IBInspectable public var bottomBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The left border color. The default is `nil`. + /// The left border color. The default is `nil`. + @IBInspectable public var leftBorderColor: UIColor? { didSet { setNeedsDisplay() From 987009025f58eddc888905cb26e63791f4d39cee Mon Sep 17 00:00:00 2001 From: Leeroy Ding Date: Wed, 16 Dec 2015 18:45:06 +0000 Subject: [PATCH 2/3] Change to original whitespace --- GradientView/GradientView.swift | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/GradientView/GradientView.swift b/GradientView/GradientView.swift index 38feae6..84c87a1 100644 --- a/GradientView/GradientView.swift +++ b/GradientView/GradientView.swift @@ -15,7 +15,7 @@ public class GradientView: UIView { // MARK: - Types /// The mode of the gradient. - public enum Type { + public enum Type { /// A linear gradient. case Linear @@ -57,7 +57,7 @@ public class GradientView: UIView { /// Automatically dim gradient colors when prompted by the system (i.e. when an alert is shown). /// - /// The default is `true`. + /// The default is `true`. public var automaticallyDims: Bool = true /// An optional array of `CGFloat`s defining the location of each gradient stop. @@ -72,56 +72,56 @@ public class GradientView: UIView { } } - /// The mode of the gradient. The default is `.Linear`. - @IBInspectable + /// The mode of the gradient. The default is `.Linear`. + @IBInspectable public var mode: Type = .Linear { didSet { setNeedsDisplay() } } - /// The direction of the gradient. Only valid for the `Mode.Linear` mode. The default is `.Vertical`. - @IBInspectable + /// The direction of the gradient. Only valid for the `Mode.Linear` mode. The default is `.Vertical`. + @IBInspectable public var direction: Direction = .Vertical { didSet { setNeedsDisplay() } } - /// 1px borders will be drawn instead of 1pt borders. The default is `true`. - @IBInspectable + /// 1px borders will be drawn instead of 1pt borders. The default is `true`. + @IBInspectable public var drawsThinBorders: Bool = true { didSet { setNeedsDisplay() } } - /// The top border color. The default is `nil`. - @IBInspectable + /// The top border color. The default is `nil`. + @IBInspectable public var topBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The right border color. The default is `nil`. - @IBInspectable + /// The right border color. The default is `nil`. + @IBInspectable public var rightBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The bottom border color. The default is `nil`. - @IBInspectable + /// The bottom border color. The default is `nil`. + @IBInspectable public var bottomBorderColor: UIColor? { didSet { setNeedsDisplay() } } - /// The left border color. The default is `nil`. - @IBInspectable + /// The left border color. The default is `nil`. + @IBInspectable public var leftBorderColor: UIColor? { didSet { setNeedsDisplay() @@ -137,7 +137,7 @@ public class GradientView: UIView { // Gradient if let gradient = gradient { - let options: CGGradientDrawingOptions = [.DrawsAfterEndLocation] + let options: CGGradientDrawingOptions = [.DrawsAfterEndLocation] if mode == .Linear { let startPoint = CGPointZero From c0d1f733d66a672831d9cc89b4f50567b3589773 Mon Sep 17 00:00:00 2001 From: Leeroy Ding Date: Wed, 16 Dec 2015 18:47:00 +0000 Subject: [PATCH 3/3] Another whitespace change --- GradientView/GradientView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GradientView/GradientView.swift b/GradientView/GradientView.swift index 84c87a1..79f095e 100644 --- a/GradientView/GradientView.swift +++ b/GradientView/GradientView.swift @@ -137,7 +137,7 @@ public class GradientView: UIView { // Gradient if let gradient = gradient { - let options: CGGradientDrawingOptions = [.DrawsAfterEndLocation] + let options: CGGradientDrawingOptions = [.DrawsAfterEndLocation] if mode == .Linear { let startPoint = CGPointZero