Commit 26efa1fb authored by Steven杜宇's avatar Steven杜宇

// 视频底部收藏点赞

parent d484ed9a
......@@ -47,9 +47,9 @@ class YHHomeWebBottomButton: UIButton {
}
}
func setContent(_ image: String, _ title: String) {
func setContent(_ image: UIImage?, _ title: String) {
bottomTitleLabel.text = title
topImageView.image = UIImage(named: image)
topImageView.image = image
}
/*
// Only override draw() if you perform custom drawing.
......
......@@ -8,7 +8,15 @@
import UIKit
enum YHTintColorMode {
case light
case dark
}
class YHHomeWebBottomView: UIView {
static let height = 59.0
typealias Block = (Bool) -> ()
var likeBlock: Block?
var starBlock: Block?
......@@ -18,27 +26,55 @@ class YHHomeWebBottomView: UIView {
var starCount: Int = 0
var isStar: Bool = false {
didSet {
var imgName = "home_web_star"
if isStar {
starButton.setContent("home_web_stared", "\(starCount)")
} else {
starButton.setContent("home_web_star", "\(starCount)")
imgName = "home_web_stared"
}
var image = UIImage(named: imgName)
if tintMode == .dark {
starButton.bottomTitleLabel.textColor = .white
if !isStar {
image = image?.withRenderingMode(.alwaysTemplate).withTintColor(.white)
starButton.topImageView.tintColor = .white
}
}
starButton.setContent(image, "\(starCount)")
}
}//是否收藏
var isLike: Bool = false {
didSet {
var imgName = "home_web_like"
if isLike {
likeButton.setContent("home_web_liked", "\(likeCount)")
} else {
likeButton.setContent("home_web_like", "\(likeCount)")
imgName = "home_web_liked"
}
var image = UIImage(named: imgName)
if tintMode == .dark {
likeButton.bottomTitleLabel.textColor = .white
if !isLike {
image = image?.withRenderingMode(.alwaysTemplate).withTintColor(.white)
likeButton.topImageView.tintColor = .white
}
}
likeButton.setContent(image, "\(likeCount)")
}
}//是否点赞
var tintMode: YHTintColorMode = .light {
didSet {
if tintMode == .light {
self.backgroundColor = .white
} else if tintMode == .dark {
self.backgroundColor = .black
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
tintMode = .light
setUpView()
}
......@@ -50,7 +86,7 @@ class YHHomeWebBottomView: UIView {
likeButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_like", "0")
button.setContent(UIImage(named:"home_web_like"), "0")
button.addTarget(self, action: #selector(likeBtnClick), for: .touchUpInside)
return button
}()
......@@ -64,7 +100,7 @@ class YHHomeWebBottomView: UIView {
starButton = {
let button = YHHomeWebBottomButton()
button.setContent("home_web_star", "0")
button.setContent(UIImage(named:"home_web_star"), "0")
button.addTarget(self, action: #selector(starBtnClick), for: .touchUpInside)
return button
}()
......
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