Add just a top border to an UIView with Quartzcore/layer?

前端 未结 8 1491
天命终不由人
天命终不由人 2020-12-13 17:58

Is it possible to add a border just on top of a UIView, if so, how please?

8条回答
  •  时光说笑
    2020-12-13 18:53

    remus' answer in Obj-C:

     CALayer *topBorder = [CALayer new];
     topBorder.frame = CGRectMake(0.0, 0.0, self.frame.size.width, 3.0);
     topBorder.backgroundColor = [UIColor redColor].CGColor;
     [myView.layer addSublayer:topBorder];
    

提交回复
热议问题