简体   繁体   中英

How to set color for separator for UITableView

How I can set the color of separator of sections? I set all posible colors to "f5f5f5", but the separator is "ededed". Why it can be?

在此处输入图片说明

Objective c

- (void)viewDidLoad
 {     
  [self.tableView setSeparatorColor:[UIColor redColor]];
 }

Swift

func viewDidLoad()
{
 self.tableview.separatorColor = UIColor.redColor
}

You can create an Extension to set a Shadow in your UITableVIewCell

extension UIView {
public func applyShadow(
    withOpacity opacity: Float = 0.4,
                offset: CGSize = CGSizeMake(2.0, 0.5),
                radius: CGFloat = 3.0) -> Void {

    self.layer.shadowOpacity = opacity
    self.layer.shadowOffset = offset
    self.layer.shadowRadius = radius
}

You can use this extension. cell.applyShadow()

To change color of Separator:

self.tableview.separatorColor = UIColor.redColor

I hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM