ProtonomeRoundedViews
ProtonomeRoundedViews 是一组具有圆形角的 IBDesignable 兼容视图。
它们以性能为导向构建,并且为了避免设置 layer.cornerRadius
,而是使用可调整大小的图像或覆盖 drawRect:
。这样做的原因是调用 layer.cornerRadius
会导致图层在 CPU 上渲染其角,如果在滚动视图内部大量执行,这可能会显著降低帧率。
此外,视图支持 IBInspectable
和 IBDesignable
以在 Interface Builder 中进行配置和预览。
类
✓ UIView -> RoundedView
✓ UILabel -> RoundedLabel
✓ UIButton -> RoundedButton
待办事项
- 探索只设置
shouldRasterize
和rasterizationScale
- 探索在
RoundedLayer
和RoundedLabel
上使用可调整大小的图像