CALayer: Single pixel line looks like 2 pixels

前端 未结 2 722
梦谈多话
梦谈多话 2021-02-04 17:08

This is my code:

int columns 3;
int columnWidth = self.layer.bounds.size.width / 3;

for (int c = 1; c < columns; c++) {
    CALayer *layer  = [CALayer layer         


        
2条回答
  •  眼角桃花
    2021-02-04 17:40

    Set the layer Frame as

    layer.frame = (CGRectMake(columnWidth * c + 0.5, 0.5, 0.5, self.layer.bounds.size.height));
    

    Yeah it will work for retina also

    Check this post Section 1 Point Lines and Pixel Boundaries.It is well explained there

提交回复
热议问题