IOS swift如何在tableView单元格内创建一条小水平线

Posted

技术标签:

【中文标题】IOS swift如何在tableView单元格内创建一条小水平线【英文标题】:IOS swift how can I create a small horizontal line inside a tableView cell 【发布时间】:2016-10-23 22:22:55 【问题描述】:

我有一个 tableView UI,我想在 TableViewCell 内的某个字段下方创建一条小水平线,例如它的外观,我想在 Location: Atlanta, GA 正下方制作水平线。这就是主情节提要的样子。我只想在原型单元格的位置字段下方创建一条细灰色水平线。任何建议都会很棒。我找到了一种创建线条的方法,但它本质上是在 TableCell 的末尾创建一个边框,这不是我需要的。

Emulator Image

ProtoType Cell

我的 TableView 代码如下

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    

        let mycell = self.StreamsTableView.dequeueReusableCell(withIdentifier: "prototype1", for: indexPath) as! HomePage_TableViewCell





        return mycell
    

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    
        tableView.backgroundColor = UIColor.clear
        return names.count
    

【问题讨论】:

【参考方案1】:

您可以在 Xcode 界面构建器中通过添加视图 (UIView) 控件并将高度设置为 1 来完成此操作。

【讨论】:

以上是关于IOS swift如何在tableView单元格内创建一条小水平线的主要内容,如果未能解决你的问题,请参考以下文章