I would like to setup an image with 2 borders around it. Is it possible to duplicate the borderWidth
property on the same image view somehow? Like this:
// inner circle/border
self.avatar.layer.borderWidth = 2.0f;
// outer circle/border
self.avatar.layer.borderWidth = 4.0f;
UIColor *myColor = [UIColor colorWithRed:(24.0 / 255.0) green:(169.0 / 255.0) blue:(250.0 / 255.0) alpha: 1];
UIColor *myColor2 = [UIColor colorWithRed:(24.0 / 255.0) green:(169.0 / 255.0) blue:(20.0 / 255.0) alpha: 1];
self.avatar.layer.borderColor = myColor.CGColor;
self.avatar.layer.borderColor = myColor2.CGColor;
Unfortunately this code doesn't work, but if there is any solution that's easy like this I would be very happy with it. Actually my only idea is to duplicate the UIImageView
, put it under the "real" image and set border for it. This way would work, but I need a cleaner solution.
For that you can add your
UIImageView
inside aUIView
and set the layer of thatUIView
.You can do it like:
Or you can add a new
CALayer
as a sublayer of your existing layer to do this.