I set the border white and radius for my ImageView
. But in 4 corner of the ImageView
, some dark line appear.
Here is the code I set the color for my ImageView
self.image.layer.cornerRadius = 10;
self.image.layer.borderWidth = 3;
self.image.layer.borderColor = [[UIColor whiteColor] CGColor];
self.image.layer.masksToBounds = YES;
This is a small demo project. My storyboard only contains the ImageView
, and I don't set any constraint for my ImageView
.
I don't know why this happened, it have tested on simulator and real device but it give a same error
Here is demo project: (it's very simple) https://drive.google.com/file/d/0B_poNaia6t8kT0JLSFJleGxEcmc/view?usp=sharing
Update
Some people give a solution is change the color of border color from whiteColor
to clearColor
. Of course it will make 4 lines disappear. But if I using clearColor
, I don't need to add border to my ImageView
.
I need border white for some reason
Updated code
I tried your code actually your image size is big initially I resized the image based on original Image size
sometimes corner radius does not work properly so I used
UIBezierPath
for this conceptfor border color and width use this
swift 3
output
Update
Swift
Output
Code for whole project
Try clip to bounds:
i tried this function written in imageview category:
at time of using:
Actually you have to use two layers.
I check your code you can change this line its work for me
self.image.layer.borderColor = [[UIColor clearColor] CGColor];
when you add a border that add in inside the image border line and when you set rounded border that time your round corner has some transparent part so that part will display in corner side just change the Color of border color