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

Merge branch 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into youhua-dev

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