Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dokgi88 committed May 3, 2019
2 parents 145bd7d + b6db9fe commit fbfc7f4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Example/GranibleLabel/GranibleViewController.swift
Expand Up @@ -39,8 +39,9 @@ class GranibleViewController: UIViewController {
label.textAlignment = .center
label.font = .boldSystemFont(ofSize: 40)
label.numberOfLines = 0
label.colors = [.pantone_roseQuartz, .pantone_livingCoral, .pantone_serenity, .pantone_roseQuartz]
label.colors = [.pantone_roseQuartz, .pantone_livingCoral, .pantone_serenity]
label.animate = true
label.infinity = true
return label
}()
private let reverseLabel: GranibleLabel = {
Expand All @@ -52,7 +53,7 @@ class GranibleViewController: UIViewController {
label.numberOfLines = 0
label.colors = [.pantone_roseQuartz, .pantone_livingCoral, .pantone_serenity]
label.animate = true
label.autoreverses = true
label.reverse = true
return label
}()

Expand Down
2 changes: 1 addition & 1 deletion GranibleLabel.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'GranibleLabel'
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = 'Very easy and simple gradation animate Label.'

# This description is used to generate tags and improve search results.
Expand Down
11 changes: 8 additions & 3 deletions GranibleLabel/Classes/GranibleLabel.swift
Expand Up @@ -39,10 +39,10 @@ public class GranibleLabel: UIView {
gradient.colors = colors.map{$0.cgColor}
}
}
public var autoreverses: Bool? {
public var reverse: Bool? {
didSet {
guard let autoreverses = autoreverses else {return}
gradientAnimation.autoreverses = autoreverses
guard let reverse = reverse else {return}
gradientAnimation.autoreverses = reverse
}
}
public var duration: Double? {
Expand All @@ -53,6 +53,7 @@ public class GranibleLabel: UIView {
}
public var direction: GranibleLabelDirection?
public var animate = false
public var infinity = false

private let gradientLabel: UILabel = {
let label = UILabel()
Expand Down Expand Up @@ -107,6 +108,10 @@ public class GranibleLabel: UIView {
}

private func setGradient() {
if infinity, let colors = colors, let firstColor = colors.first {
self.colors?.append(firstColor)
}

guard let gradientDirection = direction else {return}
switch gradientDirection {
case .top:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -26,6 +26,7 @@ pod 'GranibleLabel'
## Example

**_Up to 4 colors can be set._**
**_Up to three colors available in infinity mode._**

* Set no animation normal gradient
```swift
Expand All @@ -46,22 +47,21 @@ label.direction = .top
label.animate = true
```

* Set infinity animation
* Set infinity mode
```swift
/*
* If you set the first color and the last color the same, you can implement the infinity animation effect.
*/
label.colors = [UIColor.red, UIColor.orange, UIColor.red]
label.direction = .top
label.animate = true
label.infinity = true
```

* Set auto reverses
* Set reverse mode
```swift
/*
* autoreverses default = false
*/
label.direction = .top
label.animate = true
label.autoreverses = true
label.reverse = true
```

* And other settings
Expand Down

0 comments on commit fbfc7f4

Please sign in to comment.