Commit f82c5e77 authored by David黄金龙's avatar David黄金龙

添加渐变色

parent 748eb3de
...@@ -52,7 +52,7 @@ class YHScorePersonInfoCell: UITableViewCell { ...@@ -52,7 +52,7 @@ class YHScorePersonInfoCell: UITableViewCell {
//综合得分 //综合得分
private lazy var scoreLable : UILabel = { private lazy var scoreLable : UILabel = {
let lable0 = UILabel(text: "92") let lable0 = UILabel(text: "0")
lable0.textColor = UIColor(hex: 0xFFEEB0) lable0.textColor = UIColor(hex: 0xFFEEB0)
lable0.font = UIFont(name: "DINAlternate-Bold", size: 68) lable0.font = UIFont(name: "DINAlternate-Bold", size: 68)
lable0.textAlignment = .center lable0.textAlignment = .center
...@@ -94,6 +94,16 @@ class YHScorePersonInfoCell: UITableViewCell { ...@@ -94,6 +94,16 @@ class YHScorePersonInfoCell: UITableViewCell {
private let secondHoldView = UIView() private let secondHoldView = UIView()
var gradientLayer: CAGradientLayer = {
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [UIColor(hex: 0xFFF9E3, alpha: 1.0).cgColor, UIColor(hex: 0xFFE895, alpha: 1.0).cgColor]
gradientLayer.startPoint = CGPoint(x: 0.5, y: 0)
gradientLayer.endPoint = CGPoint(x: 0.5, y: 1)
gradientLayer.locations = [NSNumber(value: 0.2)]
gradientLayer.frame = CGRect(x: 0, y: 0, width: 200, height: 60)
return gradientLayer
}()
} }
extension YHScorePersonInfoCell { extension YHScorePersonInfoCell {
...@@ -206,21 +216,18 @@ extension YHScorePersonInfoCell { ...@@ -206,21 +216,18 @@ extension YHScorePersonInfoCell {
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
secondHoldView.addSubview(scoreLable) let width = scoreLable.requiredWidth
scoreLable.snp.makeConstraints { make in gradientLayer.frame = CGRect(x: (148 - width)/2.0, y: (105 - 80)/2.0, width: width, height: 80)
make.centerX.equalToSuperview()
make.centerY.equalToSuperview() scoreLable.layer.frame = gradientLayer.bounds
} gradientLayer.mask = scoreLable.layer
secondHoldView.layer.insertSublayer(gradientLayer, at: 0)
secondHoldView.addSubview(fenLable)
fenLable.snp.makeConstraints { make in
make.left.equalTo(scoreLable.snp.right).offset(2)
make.bottom.equalTo(scoreLable.snp.bottom).offset(-13)
}
let a: ASAttributedString = .init("-",.font(UIFont(name: "DINAlternate-Bold", size: 68) ?? UIFont.PFSC_B(ofSize: 43)),.foreground(UIColor(hex: 0xFFEEB0))) secondHoldView.addSubview(fenLable)
let b: ASAttributedString = .init("分", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex: 0xFFEEB0))) fenLable.frame = CGRect(x: gradientLayer.frame.origin.x + width, y: gradientLayer.frame.origin.y + 80 - 13 - 17 - 4, width: 18, height: 17)
scoreLable.attributed.text = a
} }
...@@ -234,27 +241,15 @@ extension YHScorePersonInfoCell { ...@@ -234,27 +241,15 @@ extension YHScorePersonInfoCell {
phoneLable.text = model.userinfo?.mobile ?? "-" phoneLable.text = model.userinfo?.mobile ?? "-"
let score : String = String(model.total_score?.sum_score ?? 0) let score : String = String(model.total_score?.sum_score ?? 0)
// let a: ASAttributedString = .init(NSAttributedString(string: score),.font(UIFont(name: "DINAlternate-Bold", size: 68) ?? UIFont.PFSC_B(ofSize: 43)),.foreground(UIColor(hex: 0xFFEEB0)))
// let b: ASAttributedString = .init("分", .font(UIFont.PFSC_M(ofSize: 16)),.foreground(.white))
// scoreLable.attributed.text = a
scoreLable.text = score scoreLable.text = score
scoreLable.layoutIfNeeded() let width = scoreLable.requiredWidth
gradientLayer.frame = CGRect(x: (148 - width)/2.0, y: (105 - 80)/2.0, width: width, height: 80)
let gradientLayer = CAGradientLayer() scoreLable.layer.frame = gradientLayer.bounds
gradientLayer.colors = [UIColor(hex: 0xFFF9E3, alpha: 1.0).cgColor, UIColor(hex: 0xFFE895, alpha: 1.0).cgColor]
gradientLayer.startPoint = CGPoint(x: 0, y: 0)
gradientLayer.endPoint = CGPoint(x: 1, y: 1)
gradientLayer.locations = [NSNumber(value: 0.2)]
gradientLayer.frame = scoreLable.bounds
gradientLayer.mask = scoreLable.layer gradientLayer.mask = scoreLable.layer
secondHoldView.layer.insertSublayer(gradientLayer, at: 0) secondHoldView.layer.insertSublayer(gradientLayer, at: 0)
fenLable.frame = CGRect(x: gradientLayer.frame.origin.x + width, y: gradientLayer.frame.origin.y + 80 - 13 - 17 - 4, width: 18, height: 17)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment