Rome Torres Rome Torres - 1 year ago 197
Swift Question

IOS swift how can I create a small horizontal line inside a tableView cell

I have a tableView UI and I would like to create a small horizontal line below a certain field inside the TableViewCell for instance this is how it looks, I would like to make the horizontal line right below the Location: Atlanta, GA . This is how the main storyboard looks . I just want to create a thin gray horizontal line below the location field in the prototype cell . Any suggestions would be great . I have found a way to create a line but it was essentially to create a border at the end of the TableCell which is not what I need.

Emulator Image

ProtoType Cell

My code for the TableView is as follows

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

Answer Source

You can to this from the Xcode interface builder by adding a View (UIView) control and set the height to 1.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download