|
@@ -20,11 +20,27 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
|
|
|
}
|
|
|
|
|
|
override func setupViews() {
|
|
|
- navigationBar.isHidden = true
|
|
|
view.addSubview(bgImageView)
|
|
|
view.addSubview(tableView)
|
|
|
- view.addSubview(communityFeaturedTopicsNavigationBarView)
|
|
|
-
|
|
|
+ view.insertSubview(navigationBar, aboveSubview: tableView)
|
|
|
+ setnavigationBar()
|
|
|
+ }
|
|
|
+
|
|
|
+ func setnavigationBar() {
|
|
|
+ navigationBar.addSubview(navigationBgView)
|
|
|
+ navigationBar.addSubview(topicLable)
|
|
|
+ navigationBar.addSubview(followButton)
|
|
|
+ navigationBar.insertSubview(navigationBgView, aboveSubview: navigationBar.backgroundImageView)
|
|
|
+ navigationBar.backgroundImageView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth)
|
|
|
+ navigationBar.clipsToBounds = true
|
|
|
+ navigationBar.wr_setLeftButton(image: kImage(name: "navbar_back_white")!)
|
|
|
+ navigationBar.wr_setRightButton(title: "我的话题", titleColor: .white)
|
|
|
+ // 设置导航栏显示图片
|
|
|
+ navigationBar.barBackgroundImage = UIImage(named: "pic_example_12")
|
|
|
+ // 设置初始导航栏透明度
|
|
|
+ navigationBar.wr_setBackgroundAlpha(alpha: 0)
|
|
|
+ // 设置状态栏style
|
|
|
+ statusBarStyle = .lightContent
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
@@ -35,9 +51,18 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
|
|
|
tableView.snp.makeConstraints { (make) in
|
|
|
make.top.left.right.bottom.equalToSuperview()
|
|
|
}
|
|
|
- communityFeaturedTopicsNavigationBarView.snp_makeConstraints { (make) in
|
|
|
- make.top.left.right.equalToSuperview()
|
|
|
- make.height.equalTo(kNavBarTotalHeight)
|
|
|
+ navigationBgView.snp_makeConstraints { (make) in
|
|
|
+ make.edges.equalTo(navigationBar)
|
|
|
+ }
|
|
|
+ topicLable.snp_makeConstraints { (make) in
|
|
|
+ make.centerY.equalTo(navigationBar.leftButton)
|
|
|
+ make.left.equalTo(navigationBar.leftButton.snp_right)
|
|
|
+ }
|
|
|
+ followButton.snp_makeConstraints { (make) in
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.centerY.equalTo(navigationBar.leftButton)
|
|
|
+ make.width.equalTo(60)
|
|
|
+ make.height.equalTo(24)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -70,7 +95,7 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
|
|
|
|
|
|
private lazy var bgImageView: UIImageView = {
|
|
|
let bgImageView = UIImageView()
|
|
|
- bgImageView.image = kImage(name: "pic_preload")
|
|
|
+ bgImageView.image = kImage(name: "pic_example_12")
|
|
|
return bgImageView
|
|
|
}()
|
|
|
|
|
@@ -79,9 +104,38 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
|
|
|
return communityFeaturedTopicsHeaderView
|
|
|
}()
|
|
|
|
|
|
- private lazy var communityFeaturedTopicsNavigationBarView: CommunityFeaturedTopicsNavigationBarView = {
|
|
|
- let communityFeaturedTopicsNavigationBarView = CommunityFeaturedTopicsNavigationBarView()
|
|
|
- return communityFeaturedTopicsNavigationBarView
|
|
|
+ private lazy var topicLable: UILabel = {
|
|
|
+ let topicLable = UILabel()
|
|
|
+ topicLable.textColor = kffffffColor
|
|
|
+ topicLable.font = kRegularFont14
|
|
|
+ topicLable.text = "运动健身"
|
|
|
+ topicLable.alpha = 0
|
|
|
+ return topicLable
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var followButton: UIButton = {
|
|
|
+ let followButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ followButton.setTitle("关注", for: UIControl.State.normal)
|
|
|
+ followButton.setImage(kImage(name: "center_attention_white"), for: UIControl.State.normal)
|
|
|
+ followButton.setImage(kImage(name: "center_followed_white"), for: UIControl.State.selected)
|
|
|
+ followButton.setBackgroundImage(UIImage.imageWithColor(color: kThemeColor), for: UIControl.State.normal)
|
|
|
+ followButton.setBackgroundImage(UIImage.imageWithColor(color: UIColor.clear), for: UIControl.State.selected)
|
|
|
+ followButton.titleLabel?.font = kMediumFont13
|
|
|
+ followButton.alpha = 0
|
|
|
+ followButton.cornerRadius = 12
|
|
|
+ followButton.masksToBounds = true
|
|
|
+ followButton.rx.tap.subscribe(onNext: {
|
|
|
+ [weak self] (data) in
|
|
|
+ followButton.isSelected = !followButton.isSelected
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return followButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var navigationBgView: UIView = {
|
|
|
+ let navigationBgView = UIView()
|
|
|
+ navigationBgView.backgroundColor = UIColor(hexString: "000000", alpha: 0.4)
|
|
|
+ navigationBgView.alpha = 0
|
|
|
+ return navigationBgView
|
|
|
}()
|
|
|
|
|
|
/// 关注接口
|
|
@@ -90,6 +144,31 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+extension CommunityFeaturedTopicsViewController
|
|
|
+{
|
|
|
+ func scrollViewDidScroll(_ scrollView: UIScrollView)
|
|
|
+ {
|
|
|
+ let offsetY = scrollView.contentOffset.y
|
|
|
+ if (offsetY > kSafeStatusBarHeight)
|
|
|
+ {
|
|
|
+ let alpha = (offsetY - kSafeStatusBarHeight) / CGFloat(kNavBarTotalHeight)
|
|
|
+ navigationBar.wr_setBackgroundAlpha(alpha: alpha)
|
|
|
+ followButton.alpha = alpha
|
|
|
+ topicLable.alpha = alpha
|
|
|
+ navigationBgView.alpha = alpha
|
|
|
+ navigationBar.rightButton.alpha = 1 - alpha
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ navigationBar.wr_setBackgroundAlpha(alpha: 0)
|
|
|
+ followButton.alpha = 0
|
|
|
+ topicLable.alpha = 0
|
|
|
+ navigationBgView.alpha = 0
|
|
|
+ navigationBar.rightButton.alpha = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
extension CommunityFeaturedTopicsViewController : UITableViewDelegate,UITableViewDataSource {
|
|
|
func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
return 15
|