|
| 1 | +// |
| 2 | +// DummyFooterView.swift |
| 3 | +// Falling |
| 4 | +// |
| 5 | +// Created by SeungMin on 5/26/24. |
| 6 | +// |
| 7 | + |
| 8 | +import UIKit |
| 9 | + |
| 10 | +import DSKit |
| 11 | + |
| 12 | +final class DummyFooterView: UICollectionReusableView { |
| 13 | + private lazy var cardTimeView = CardTimeView() |
| 14 | + |
| 15 | + override init(frame: CGRect) { |
| 16 | + super.init(frame: .zero) |
| 17 | + |
| 18 | + configureUI() |
| 19 | + makeUI() |
| 20 | + } |
| 21 | + |
| 22 | + required init?(coder: NSCoder) { |
| 23 | + fatalError("init(coder:) has not been implemented") |
| 24 | + } |
| 25 | + |
| 26 | + private func configureUI() { |
| 27 | + layer.borderWidth = 1 |
| 28 | + layer.cornerRadius = 20 |
| 29 | + clipsToBounds = true |
| 30 | +// backgroundColor = .blue |
| 31 | +// layer.borderColor = UIColor.orange.cgColor |
| 32 | + |
| 33 | + addGradientBackground() |
| 34 | + addGradientBorder() |
| 35 | + } |
| 36 | + |
| 37 | + private func makeUI() { |
| 38 | + addSubview(cardTimeView) |
| 39 | + |
| 40 | + cardTimeView.snp.makeConstraints { |
| 41 | + $0.top.leading.trailing.equalToSuperview().inset(12) |
| 42 | + $0.height.equalTo(32) |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + private func addGradientBackground() { |
| 47 | + let gradientLayer = CAGradientLayer() |
| 48 | + gradientLayer.frame = bounds |
| 49 | + |
| 50 | + gradientLayer.colors = [ |
| 51 | + DSKitAsset.Color.DummyUserGradient.backgroundFirst.color, |
| 52 | + DSKitAsset.Color.DummyUserGradient.backgroundSecond.color, |
| 53 | + DSKitAsset.Color.DummyUserGradient.backgroundFirst.color |
| 54 | + ] |
| 55 | + |
| 56 | + gradientLayer.locations = [0.0, 0.5, 1.0] |
| 57 | + |
| 58 | + gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0) |
| 59 | + gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0) |
| 60 | + |
| 61 | +// layer.addSublayer(gradientLayer) |
| 62 | + |
| 63 | + layer.insertSublayer(gradientLayer, at: 0) |
| 64 | + } |
| 65 | + |
| 66 | + private func addGradientBorder() { |
| 67 | + let gradientLayer = CAGradientLayer() |
| 68 | + gradientLayer.frame = bounds |
| 69 | + |
| 70 | + gradientLayer.colors = [ |
| 71 | + DSKitAsset.Color.DummyUserGradient.borderFirst.color, |
| 72 | + DSKitAsset.Color.DummyUserGradient.borderSecond.color |
| 73 | + ] |
| 74 | + |
| 75 | +// gradientLayer.locations = [0.0, 0.5, 1.0] |
| 76 | + |
| 77 | + gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0) |
| 78 | + gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0) |
| 79 | + |
| 80 | + let shapeLayer = CAShapeLayer() |
| 81 | + let path = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius) |
| 82 | + shapeLayer.path = path.cgPath |
| 83 | + shapeLayer.lineWidth = 1 |
| 84 | + shapeLayer.fillColor = DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor |
| 85 | + shapeLayer.strokeColor = DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor |
| 86 | + |
| 87 | + gradientLayer.mask = shapeLayer |
| 88 | + |
| 89 | +// layer.addSublayer(gradientLayer) |
| 90 | + |
| 91 | + layer.insertSublayer(gradientLayer, at: 0) |
| 92 | + } |
| 93 | +} |
0 commit comments