Skip to content

Commit

Permalink
Design:iphone:: #196 Add category radius
Browse files Browse the repository at this point in the history
  • Loading branch information
JUNY0110 committed Dec 14, 2022
1 parent 40e9801 commit c35c7c0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Samsam/ViewController/PostingView/CategoryCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class CategoryCell: UICollectionViewCell {
let gradientBackground: UIView = {
$0.backgroundColor = .black
$0.layer.opacity = 0.4
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 8
$0.underRadius()
return $0
}(UIView())

Expand Down Expand Up @@ -104,19 +107,32 @@ class CategoryCell: UICollectionViewCell {

func selectCell(_ uiView: UIView, image: UIImageView) {
UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut, animations: {
self.gradientBackground.layer.opacity = 0.7

self.gradientBackground.layer.frame = CGRect(x: 0, y: 0, width: self.categoryImage.frame.width, height: self.categoryImage.frame.height)
self.categoryName.layer.frame = CGRect(x: 0, y: 0, width: self.categoryImage.frame.width, height: self.categoryImage.frame.height)

self.gradientBackground.layer.opacity = 0.7
self.gradientBackground.allRadius()

self.layoutIfNeeded()
})
}

func deSelectCell(_ uiView: UIView, image: UIImageView) {
UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut, animations: {
self.gradientBackground.layer.opacity = 0.4
self.gradientBackground.underRadius()

self.layoutIfNeeded()
})
}
}


extension UIView {
func underRadius() {
self.layer.maskedCorners = CACornerMask(arrayLiteral: .layerMinXMaxYCorner, .layerMaxXMaxYCorner)
}
func allRadius() {
self.layer.maskedCorners = CACornerMask(arrayLiteral: .layerMinXMinYCorner, .layerMaxXMinYCorner, .layerMaxXMaxYCorner, .layerMinXMaxYCorner)
}
}

0 comments on commit c35c7c0

Please sign in to comment.