Commit 0adb1fa0 authored by Alex朱枝文's avatar Alex朱枝文

UI走查问题修复

parent 4a2a200b
......@@ -315,7 +315,6 @@
04564D5F2CF565C7004456E4 /* YHInputBottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */; };
04564D612CF59835004456E4 /* YHMessageInputViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D602CF59835004456E4 /* YHMessageInputViewController.swift */; };
04564D632CF60222004456E4 /* YHGradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D622CF60222004456E4 /* YHGradientView.swift */; };
04564D652CF6065D004456E4 /* YHFadeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D642CF6065D004456E4 /* YHFadeView.swift */; };
04564D682CF6BFA0004456E4 /* YHLiveSalesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D672CF6BFA0004456E4 /* YHLiveSalesViewModel.swift */; };
04564D6A2CF6C0FC004456E4 /* YHLiveDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D692CF6C0FC004456E4 /* YHLiveDetailModel.swift */; };
04564D6C2CF6C414004456E4 /* YHLivePlayerViewController+Api.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D6B2CF6C414004456E4 /* YHLivePlayerViewController+Api.swift */; };
......@@ -1434,7 +1433,6 @@
04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInputBottomBar.swift; sourceTree = "<group>"; };
04564D602CF59835004456E4 /* YHMessageInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMessageInputViewController.swift; sourceTree = "<group>"; };
04564D622CF60222004456E4 /* YHGradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGradientView.swift; sourceTree = "<group>"; };
04564D642CF6065D004456E4 /* YHFadeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFadeView.swift; sourceTree = "<group>"; };
04564D672CF6BFA0004456E4 /* YHLiveSalesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveSalesViewModel.swift; sourceTree = "<group>"; };
04564D692CF6C0FC004456E4 /* YHLiveDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveDetailModel.swift; sourceTree = "<group>"; };
04564D6B2CF6C414004456E4 /* YHLivePlayerViewController+Api.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "YHLivePlayerViewController+Api.swift"; sourceTree = "<group>"; };
......@@ -3093,7 +3091,6 @@
04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */,
04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */,
04564D622CF60222004456E4 /* YHGradientView.swift */,
04564D642CF6065D004456E4 /* YHFadeView.swift */,
04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */,
04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */,
04564D7D2CF8D03D004456E4 /* YHFloatingWindow.swift */,
......@@ -6681,7 +6678,6 @@
042B20DA2CEB337100655093 /* YHImproveSchemeTemplateListCell.swift in Sources */,
0445E6AF2BE9CFF6003C52F9 /* YHAppVersionForceUpdateView.swift in Sources */,
040AE9882CEB6DAC00310241 /* YHWorkExperiencePositionModel.swift in Sources */,
04564D652CF6065D004456E4 /* YHFadeView.swift in Sources */,
04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */,
041892262C91BDF500B9FB94 /* YHResignDocumentHeaderCell.swift in Sources */,
04564D802CF8E16C004456E4 /* YHPlayerTransitionAnimator.swift in Sources */,
......
//
// YHFadeView.swift
// galaxy
//
// Created by alexzzw on 2024/11/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFadeView: UIView {
private let maskLayer = CAGradientLayer()
override init(frame: CGRect) {
super.init(frame: frame)
setupMask()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupMask()
}
private func setupMask() {
// 使用黑色渐变作为mask
maskLayer.colors = [
UIColor.black.cgColor,
UIColor.clear.cgColor,
]
maskLayer.startPoint = CGPoint(x: 0, y: 0)
maskLayer.endPoint = CGPoint(x: 0, y: 1)
// 重要:将渐变层设置为mask
layer.mask = maskLayer
}
override func layoutSubviews() {
super.layoutSubviews()
// 确保mask大小与视图相同
maskLayer.frame = bounds
}
}
......@@ -15,13 +15,6 @@ class YHLiveMessageListView: UIView {
// MARK: - UI Components
private lazy var topFadeView: YHFadeView = {
let view = YHFadeView()
view.isHidden = true
view.backgroundColor = .clear.withAlphaComponent(0.1)
return view
}()
private lazy var tableView: UITableView = {
let view = UITableView()
view.backgroundColor = .clear
......@@ -49,12 +42,6 @@ class YHLiveMessageListView: UIView {
private func setupUI() {
backgroundColor = .clear
addSubview(tableView)
addSubview(topFadeView)
bringSubviewToFront(topFadeView)
topFadeView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(26)
}
tableView.snp.makeConstraints { make in
make.top.equalToSuperview()
......@@ -81,6 +68,27 @@ class YHLiveMessageListView: UIView {
// MARK: - UITableViewDelegate & UITableViewDataSource
extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let fadeRange: CGFloat = 50
tableView.visibleCells.forEach { cell in
guard let indexPath = tableView.indexPath(for: cell) else { return }
let cellRect = tableView.rectForRow(at: indexPath)
// 因为视图是倒置的,所以我们需要用 tableView 的高度来计算正确的位置
let cellPositionFromBottom = tableView.bounds.height - (cellRect.origin.y - scrollView.contentOffset.y) - cellRect.height
if cellPositionFromBottom >= 0 && cellPositionFromBottom <= fadeRange {
let progress = cellPositionFromBottom / fadeRange
cell.alpha = progress
} else if cellPositionFromBottom > fadeRange {
cell.alpha = 1.0
} else {
cell.alpha = 0.0
}
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
......
......@@ -283,7 +283,7 @@ class YHLiveShopViewCell: UITableViewCell {
}
func setupUI() {
//self.backgroundColor = .white
self.backgroundColor = .clear
lineView = {
let view = UIView()
......
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