Is it possible to add a border style to a UITableView? (Not BorderColor/BorderWidth)

后端 未结 5 669
逝去的感伤
逝去的感伤 2020-12-29 15:40

Is it possible to add a border style to a UITableView?

Not just bordercolor and borderwidth.

For example a grooved border style?

5条回答
  •  星月不相逢
    2020-12-29 16:01

    Hey You can give border to your views using CALayer which is available in QuartzCore Framework

    Following link will help you to understand CALayer in detail.

    Introduction to CALayers Tutorial

    For example from the above link,

    // Import QuartzCore.h at the top of the file
    #import 
    
    // In viewDidLoad add the following lines
    self.view.layer.backgroundColor = [UIColor orangeColor].CGColor;
    self.view.layer.cornerRadius = 20.0;
    self.view.layer.frame = CGRectInset(self.view.layer.frame, 20, 20);
    
    
    CALayer *sublayer = [CALayer layer];
    sublayer.backgroundColor = [UIColor blueColor].CGColor;
    sublayer.shadowOffset = CGSizeMake(0, 5);
    sublayer.shadowRadius = 5.0;
    sublayer.shadowColor = [UIColor blackColor].CGColor;
    sublayer.shadowOpacity = 1.0;
    sublayer.frame = CGRectMake(30, 30, 128, 192);
    [self.view.layer addSublayer:sublayer];
    

    Though above code will not give you exact grooved effect. But you can try with it.

提交回复
热议问题