iOS虚线边框

CAShapeLayer * borderLayer = [CAShapeLayer layer];
    borderLayer.bounds = sender.bounds;
    borderLayer.position = CGPointMake(CGRectGetMidX(sender.bounds), CGRectGetMidY(sender.bounds));
    borderLayer.path = [UIBezierPath bezierPathWithRoundedRect:borderLayer.bounds cornerRadius:4.f].CGPath;
    borderLayer.lineWidth = 1/[[UIScreen mainScreen]scale];
    borderLayer.lineDashPattern = @[@2,@2];
    borderLayer.fillColor = [UIColor clearColor].CGColor;
    borderLayer.strokeColor = [UIColor whiteColor].CGColor;
    [sender.layer addSublayer:borderLayer];

猜你喜欢

转载自blog.csdn.net/a787188834/article/details/83022508
今日推荐