i have following code make uiimageview
in each of uitableview's cells have rounded corners:
- (void)awakefromnib { // rounded corners. [[cellimage layer] setcornerradius:([cellimage frame].size.height / 2)]; [[cellimage layer] setmaskstobounds:yes]; [[cellimage layer] setbordercolor:[[uicolor whitecolor] cgcolor]]; [[cellimage layer] setborderwidth:3]; // trouble! }
i want images have bit of gap between them, , figured make use of border width make happen. below image of happened:
it's faint black border want know how rid of. i'd think there's way of doing using border width. if not, best approach might resize image , set border width 0.
rather using corner radius, can create bezier path mask, create shape layer path, , specify shape layer image view's layer's mask:
cgfloat margin = 3.0; cgrect rect = cgrectinset(imageview.bounds, margin, margin); uibezierpath *path = [uibezierpath bezierpathwitharccenter:cgpointmake(imageview.bounds.size.width/2, imageview.bounds.size.height/2) radius:radius startangle:0 endangle:m_pi*2 clockwise:no]; cashapelayer *mask = [cashapelayer layer]; mask.path = path.cgpath; imageview.layer.mask = mask;
Comments
Post a Comment