gpt4 book ai didi

ios - UITableView 滚动时遇到的问题

转载 作者:行者123 更新时间:2023-11-28 15:22:42 24 4
gpt4 key购买 nike

我创建了一个 UITableView,然后我给 TableView 添加了阴影。但是当我将阴影应用于 table view 时滚动效果出现了一些问题并且没有提供正确的滚动效果。

下面是影子代码:

extension UIView {
func shadow() {
self.layer.shadowColor = UIColor.lightGray.cgColor
self.layer.shadowOffset = CGSize(width: 0, height: -1)
self.layer.shadowRadius = 4.0
self.layer.shadowOpacity = 0.5
self.layer.masksToBounds = false
}
}

我的 TableViewControl.swift 文件的 viewDidLoad() 代码是:

 override func viewDidLoad() {
super.viewDidLoad()
tableView.shadow() //If I comment this line, so output became Proper
}

错误看起来像这样(tableView 滚动到 tableView 区域之外):

enter image description here

我该如何解决这个问题?

最佳答案

self.layer.masksToBounds = true
self.layer.clipToBounds = true

enter image description here

检查剪辑到 UITableView 的边界。

请试试这个。

关于ios - UITableView 滚动时遇到的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45710282/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com