Tapas Pal
Tapas Pal

Reputation: 7207

cornerRadius showing background colour in corners

enter image description here

To achieve the above design I use the below code. Every thing is perfect.

for(....)
{
    CALayer *layer=[CALayer layer];
    [layer setFrame:CGRectMake(xAxis, 2.0f, width, height)];
    [layer setBackgroundColor:[self getColor:colorId]];
    [[self layer] addSublayer:layer];
}

I have use cornerRadious for rounding the corner. And the problem is on corners it's shows the background colours little bit. Can anybody please suggest me what to do. I am using below code for cornerRadious. Thanks in advance.

[[vBarHolder layer] setCornerRadius:3.0f];
[[vBarHolder layer] setBorderColor:[[UIColor whiteColor] CGColor]];
[[vBarHolder layer] setBorderWidth:2.0f];
[[vBarHolder layer] setMasksToBounds:YES];
[vBarHolder setClipsToBounds:YES];

Upvotes: 0

Views: 77

Answers (1)

Amit Kalghatgi
Amit Kalghatgi

Reputation: 367

Your coloured views are overlapped by vBarHolder. Modify the code as below.

for(....)
{
     CALayer *layer=[CALayer layer];
     [layer setFrame:CGRectMake(xAxis + 2, 2.0f + 2, width - 4 , height- 4)];
     [layer setBackgroundColor:[self getColor:colorId]];
     [[self layer] addSublayer:layer];
}

as the layers are having corner radius as 0 you are able to see in background.

Regards,

Amit

Upvotes: 1

Related Questions