Skip to content

Commit

Permalink
Add cornerRadius property to ScalingCarouselCell (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa authored Jul 20, 2020
1 parent 847b88b commit 2e1748e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Example/ScalingCarousel/StoryboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ extension CarouselDatasource: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)


if let scalingCell = cell as? ScalingCarouselCell {
scalingCell.mainView.backgroundColor = .red
scalingCell.cornerRadius = 40
}

DispatchQueue.main.async {
Expand Down
5 changes: 4 additions & 1 deletion ScalingCarousel/Classes/ScalingCarouselCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ open class ScalingCarouselCell: UICollectionViewCell {
/// The minimum value to alpha to, should be set between 0 and 1
open var alphaMinimum: CGFloat = 0.85

/// The corner radius value of the cell's main view
open var cornerRadius: CGFloat = 20.0

// MARK: - IBOutlets

// This property should be connected to the main cell subview
Expand Down Expand Up @@ -87,6 +90,6 @@ open class ScalingCarouselCell: UICollectionViewCell {
mainView.alpha = alphaValue

// ..also..round the corners
mainView.layer.cornerRadius = 20
mainView.layer.cornerRadius = cornerRadius
}
}

0 comments on commit 2e1748e

Please sign in to comment.