update color
This commit is contained in:
parent
74eea1ac2d
commit
e95afdc249
@ -112,7 +112,9 @@ import UIKit
|
||||
//if number of colors is even, need to display gradient layer, otherwise make top layer as solid color layer
|
||||
if graphObject.colors.count % 2 == 0 {
|
||||
leftColors.removeLast()
|
||||
topLayer.colors = [leftColors.last!, rightColors.first!]
|
||||
let firstColor = leftColors.last!.uiColor.cgColor
|
||||
let secondColor = rightColors.first!.uiColor.cgColor
|
||||
topLayer.colors = [firstColor, secondColor]
|
||||
} else {
|
||||
topLayer.backgroundColor = leftColors.last?.uiColor.cgColor
|
||||
}
|
||||
@ -125,7 +127,9 @@ import UIKit
|
||||
|
||||
//count of graidentLayer.colors must be bigger than 1, otherwise set backgroundColor
|
||||
if leftColors.count > 1 {
|
||||
leftLayer.colors = Array(leftColors)
|
||||
leftLayer.colors = leftColors.map({ (color) -> CGColor in
|
||||
return color.uiColor.cgColor
|
||||
})
|
||||
} else {
|
||||
leftLayer.backgroundColor = leftColors.first?.uiColor.cgColor
|
||||
}
|
||||
@ -136,7 +140,9 @@ import UIKit
|
||||
rightLayer.startPoint = CGPoint(x: 0, y: 0)
|
||||
rightLayer.endPoint = CGPoint(x: 0, y: 1)
|
||||
if rightColors.count > 1 {
|
||||
rightLayer.colors = Array(rightColors)
|
||||
rightLayer.colors = rightColors.map({ (color) -> CGColor in
|
||||
return color.uiColor.cgColor
|
||||
})
|
||||
} else {
|
||||
rightLayer.backgroundColor = rightColors.first?.uiColor.cgColor
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user