Can anybody please explain which is the right way to draw a dotted rectangular border around UILabel
which can be resized and movable, I have searched a lot, found 2 ways:
First is,
_border = [CAShapeLayer layer];
_border.strokeColor = [UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor;
_border.fillColor = nil;
_border.lineDashPattern = @[@4, @2];
[self.layer addSublayer:_border];
And in your layoutsubviews, put this:
_border.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
_border.frame = self.bounds;
Second is,
It could be done by drawing a border around NSAttributed
String in UILabel
Issues:
- Since for resizing the
UILabel
based on user touch,already I am changing its size touch methods,again I need to write bunch of lines to resize the border layer - Didn't get the approach to draw border on away from text not on text itself.
Can anybody please help in sorting the optimized approach.