1.iOS画虚线边框layer.border
// 给self.view画一个类似self.layer.border的虚线边框
CAShapeLayer *border = [CAShapeLayer layer];
border.strokeColor = SLColorLine.CGColor;
border.fillColor = nil;
border.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
border.frame = self.bounds;
border.lineWidth = 1.f;
border.lineCap = @"square";
border.lineDashPattern = @[@4, @2];
[self.layer addSublayer:border];
2.iOS画小于1px的细线
CALayer *layer = view.layer;
layer.borderColor = [UIColor whiteColor].CGColor;
layer.borderWidth = (1.0 / [UIScreen mainScreen].scale / 2);
3.iOS 设置行距,并且计算有行距的文本高度
[text addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0, text.length)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:5];//调整行间距
[text addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
[self.topicDeatil.article.content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:16] ,NSParagraphStyleAttributeName : paragraphStyle} context:nil].size.height ;
网友评论