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的細(xì)線
CALayer *layer = view.layer;
layer.borderColor = [UIColor whiteColor].CGColor;
layer.borderWidth = (1.0 / [UIScreen mainScreen].scale / 2);
3.iOS 設(shè)置行距牌借,并且計算有行距的文本高度
[text addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0, text.length)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:5];//調(diào)整行間距
[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 ;