Skip to content

Commit

Permalink
[#79]Feat: 좋아요 버튼 클릭 시, 원형 timer, progress 그레디언트 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Minny27 authored and ibcylon committed May 27, 2024
1 parent 6402f5d commit ea9e4ba
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Projects/Features/Falling/Src/Subviews/CardCircleTimerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ final class CardCircleTimerView: TFBaseView {
return layer
}()

private lazy var likeImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = DSKitAsset.Image.Icons.cardLike.image.withTintColor(DSKitAsset.Color.error.color)
return imageView
}()

override func makeUI() {
layer.addSublayer(trackLayer)
layer.addSublayer(strokeLayer)
Expand Down Expand Up @@ -81,4 +87,52 @@ final class CardCircleTimerView: TFBaseView {
clockwise: true)
dotLayer.path = dotPath.cgPath
}

func addGradientLayer() {
self.addSubview(likeImageView)

likeImageView.snp.makeConstraints {
$0.centerX.centerY.equalToSuperview()
$0.width.equalTo(8)
$0.height.equalTo(7)
}

let gradientLayer = CAGradientLayer()

gradientLayer.frame = self.bounds

gradientLayer.colors = [
DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor,
DSKitAsset.Color.LikeGradient.gradientSecond.color.cgColor,
DSKitAsset.Color.LikeGradient.gradientThird.color.cgColor
]

gradientLayer.locations = [0.0, 0.5, 1.0]

gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)

gradientLayer.mask = trackLayer

layer.addSublayer(gradientLayer)

// // 그라디언트 방향 애니메이션 설정
// let startPointAnimation = CABasicAnimation(keyPath: "startPoint")
// startPointAnimation.fromValue = CGPoint(x: 0.5, y: 0.0)
// startPointAnimation.toValue = CGPoint(x: 0.5, y: 1.0)
//
// let endPointAnimation = CABasicAnimation(keyPath: "endPoint")
// endPointAnimation.fromValue = CGPoint(x: 0.5, y: 1.0)
// endPointAnimation.toValue = CGPoint(x: 0.5, y: 0.0)
//
// // 애니메이션 설정 (동일한 타이밍으로 적용)
// let animationGroup = CAAnimationGroup()
// animationGroup.animations = [startPointAnimation, endPointAnimation]
// animationGroup.duration = 2.0
// animationGroup.autoreverses = true
// animationGroup.repeatCount = .infinity
//
// // 그라디언트 레이어에 애니메이션 추가
// gradientLayer.add(animationGroup, forKey: "gradientMove")
}
}
19 changes: 19 additions & 0 deletions Projects/Features/Falling/Src/Subviews/CardProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,23 @@ final class CardProgressView: TFBaseView {
self.layer.masksToBounds = true
self.backgroundColor = DSKitAsset.Color.neutral600.color
}

func addGradientLayer() {
let gradientLayer = CAGradientLayer()

gradientLayer.frame = self.bounds

gradientLayer.colors = [
DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor,
DSKitAsset.Color.LikeGradient.gradientSecond.color.cgColor,
DSKitAsset.Color.LikeGradient.gradientThird.color.cgColor
]

gradientLayer.locations = [0.0, 0.5, 1.0]

gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.5)
gradientLayer.endPoint = CGPoint(x: 1.0, y: 0.5)

layer.addSublayer(gradientLayer)
}
}

0 comments on commit ea9e4ba

Please sign in to comment.