Skip to content

Commit

Permalink
Optimize masking #42
Browse files Browse the repository at this point in the history
  • Loading branch information
lbrndnr committed Aug 29, 2015
1 parent 49ae18e commit bcc6891
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ class SheetCollectionViewCell: UICollectionViewCell {
}
}

private var needsMasking: Bool {
guard backgroundInsets == UIEdgeInsets() else {
return true
}

switch roundedCorners {
case .None:
return false
default:
return true
}
}

// MARK: - Initialization

override init(frame: CGRect) {
Expand Down Expand Up @@ -97,7 +110,7 @@ class SheetCollectionViewCell: UICollectionViewCell {
// MARK: - Mask

private func reloadMask() {
if layer.mask == nil {
if needsMasking && layer.mask == nil {
let maskLayer = CAShapeLayer()
maskLayer.frame = bounds
maskLayer.lineWidth = 0
Expand Down

0 comments on commit bcc6891

Please sign in to comment.