creating border for uitableview

后端 未结 3 804
再見小時候
再見小時候 2020-12-14 16:47

I am using a uitableview and scrollview in a uiview. How to set a border for table or scrollview?

相关标签:
3条回答
  • 2020-12-14 17:30

    This works quite well for me:

    CALayer *layer = _tableView.layer;
    [layer setMasksToBounds:YES];
    [layer setCornerRadius: 4.0];
    [layer setBorderWidth:1.0];
    [layer setBorderColor:[[UIColor colorWithWhite: 0.8 alpha: 1.0] CGColor]];
    

    The rounded borders look a little more iOS.

    0 讨论(0)
  • 2020-12-14 17:32
    #import  "QuartzCore/QuartzCore.h"
    

    then in viewDidLoad use,

    tableView.layer.borderWidth = 2.0;
    

    Note

    You can also set the border color:

    tableView.layer.borderColor = [UIColor redColor].CGColor;
    

    It should work for you. :)

    0 讨论(0)
  • 2020-12-14 17:42

    if you want to give the border to tableview with color, use below code for swift 3

    yourTableViewName.layer.borderColor = UIColor.gray.cgColor
    yourTableViewName.layer.borderWidth = 1.0
    
    0 讨论(0)
提交回复
热议问题