Setting multiple borders on UIView

后端 未结 5 454
庸人自扰
庸人自扰 2021-01-13 17:39

As I cannot find any questions/answers for this, I imagine it is not possible.

Is there anyway to set multiple borders on a UIView.

I am curren

5条回答
  •  被撕碎了的回忆
    2021-01-13 18:24

    Try this,

    I'm adding shadow with alpha 1 which will act as the inner border. And the normal border is given as outer border.

    yourView.frame = CGRectInset(yourView.frame, -borderWidth, -borderWidth);
    yourView.layer.borderColor = [UIColor blackColor].CGColor;
    yourView.layer.borderWidth = borderWidth;
    
    
    yourView.layer.shadowColor = [UIColor whiteColor].CGColor;
    yourView.layer.shadowOffset = CGSizeMake(0, 1);
    yourView.layer.shadowOpacity = 1;
    yourView.layer.shadowRadius = 1.0;
    yourView.clipsToBounds = YES;
    

提交回复
热议问题