How to get differentiating gap between two tableview cells in a tableview? [duplicate]












1
















This question already has an answer here:




  • How to add spacing between UITableViewCell

    22 answers




I have tried this code but it didn't work for me:



let whiteBackgroundLayerView: UIView = UIView(frame: CGRect(x: 10 , y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteBackgroundLayerView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteBackgroundLayerView.layer.masksToBounds = false
whiteBackgroundLayerView.layer.cornerRadius = 2.0
cell.contentView.addSubview(whiteBackgroundLayerView)
cell.contentView.sendSubviewToBack(whiteBackgroundLayerView)


I want the output be like this:



enter image description here










share|improve this question















marked as duplicate by Community Nov 26 '18 at 12:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

    – Rakesha Shastri
    Nov 25 '18 at 9:56


















1
















This question already has an answer here:




  • How to add spacing between UITableViewCell

    22 answers




I have tried this code but it didn't work for me:



let whiteBackgroundLayerView: UIView = UIView(frame: CGRect(x: 10 , y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteBackgroundLayerView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteBackgroundLayerView.layer.masksToBounds = false
whiteBackgroundLayerView.layer.cornerRadius = 2.0
cell.contentView.addSubview(whiteBackgroundLayerView)
cell.contentView.sendSubviewToBack(whiteBackgroundLayerView)


I want the output be like this:



enter image description here










share|improve this question















marked as duplicate by Community Nov 26 '18 at 12:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

    – Rakesha Shastri
    Nov 25 '18 at 9:56
















1












1








1









This question already has an answer here:




  • How to add spacing between UITableViewCell

    22 answers




I have tried this code but it didn't work for me:



let whiteBackgroundLayerView: UIView = UIView(frame: CGRect(x: 10 , y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteBackgroundLayerView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteBackgroundLayerView.layer.masksToBounds = false
whiteBackgroundLayerView.layer.cornerRadius = 2.0
cell.contentView.addSubview(whiteBackgroundLayerView)
cell.contentView.sendSubviewToBack(whiteBackgroundLayerView)


I want the output be like this:



enter image description here










share|improve this question

















This question already has an answer here:




  • How to add spacing between UITableViewCell

    22 answers




I have tried this code but it didn't work for me:



let whiteBackgroundLayerView: UIView = UIView(frame: CGRect(x: 10 , y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteBackgroundLayerView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteBackgroundLayerView.layer.masksToBounds = false
whiteBackgroundLayerView.layer.cornerRadius = 2.0
cell.contentView.addSubview(whiteBackgroundLayerView)
cell.contentView.sendSubviewToBack(whiteBackgroundLayerView)


I want the output be like this:



enter image description here





This question already has an answer here:




  • How to add spacing between UITableViewCell

    22 answers








ios swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 11:20









Rakesha Shastri

7,12221334




7,12221334










asked Nov 25 '18 at 9:49









B SAI DEERAJB SAI DEERAJ

23




23




marked as duplicate by Community Nov 26 '18 at 12:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Community Nov 26 '18 at 12:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

    – Rakesha Shastri
    Nov 25 '18 at 9:56





















  • Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

    – Rakesha Shastri
    Nov 25 '18 at 9:56



















Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

– Rakesha Shastri
Nov 25 '18 at 9:56







Again, what do you get now? Also, please tag your question appropriately. Xcode is for problems you have with your Xcode IDE.

– Rakesha Shastri
Nov 25 '18 at 9:56














1 Answer
1






active

oldest

votes


















0














In your custom cell, add the following code:



override func layoutSubviews() {
super.layoutSubviews()
contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
}





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    In your custom cell, add the following code:



    override func layoutSubviews() {
    super.layoutSubviews()
    contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
    }





    share|improve this answer




























      0














      In your custom cell, add the following code:



      override func layoutSubviews() {
      super.layoutSubviews()
      contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
      }





      share|improve this answer


























        0












        0








        0







        In your custom cell, add the following code:



        override func layoutSubviews() {
        super.layoutSubviews()
        contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
        }





        share|improve this answer













        In your custom cell, add the following code:



        override func layoutSubviews() {
        super.layoutSubviews()
        contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 9:55









        DamonDamon

        523318




        523318















            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Contact image not getting when fetch all contact list from iPhone by CNContact

            Calculate evaluation metrics using cross_val_predict sklearn