Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IBDesignable and IBInspectable #13

Merged
merged 3 commits into from
Dec 16, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add IBDesignable and IBInspectable
  • Loading branch information
LeeroyDing committed Oct 27, 2015
commit 619511c39c0c3abddf66065fcf38e7f0f8384a8b
26 changes: 17 additions & 9 deletions GradientView/GradientView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down