Skip to content

Commit

Permalink
When star points is less than 3, use 5 as default.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeLin committed Feb 14, 2016
1 parent 5f0bcd8 commit c1bd8a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions IBAnimatable/MaskDesignable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ public extension MaskDesignable where Self: UIView {
public func maskStar(points: Int = 5) {
// FIXME: Do not mask the shadow.

assert(points >= 2, "Stars must has at least 2 points.")
// Stars must has at least 3 points.
var starPoints = points
if points <= 2 {
starPoints = 5
}
layer.mask?.removeFromSuperlayer()
layer.sublayers?
.filter { $0.name == "borderSideLayer" || $0.name == "borderLayer" }
.forEach { $0.removeFromSuperlayer() }

let path = starPath(points)
let path = starPath(starPoints)
drawPath(path)
}

Expand Down

0 comments on commit c1bd8a7

Please sign in to comment.