如何在 UIView
周围添加虚线边框。
类似的东西
最佳答案
如果你喜欢子层,另一种方法。在自定义 View 的 init 中,输入以下内容(_border 是 ivar):
_border = [CAShapeLayer layer];
_border.strokeColor = [UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor;
_border.fillColor = nil;
_border.lineDashPattern = @[@4, @2];
[self.layer addSublayer:_border];
在你的布局 subview 中,放这个:
_border.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
_border.frame = self.bounds;
关于ios - UIView 周围的虚线边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13679923/