我打破我的头线之间增加更多的空间。 如果有人告诉什么需要做的,这将是很有益的。
使用NSMutableParagraphStyle这个问题可以固定的,但部署目标是不支持ios5.So NSMutableParagraphStyle。
字体大小:18线间隙30
码:
CustomNote.h
@interface CustomNote : UITextView<UIScrollViewDelegate,
UITextViewDelegate>{ } @end
CustomNote.m
@implementation CustomNote
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.delegate = self;
}
return self;
}
-(void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.2f].CGColor);
CGContextSetLineWidth(context, 1.0f);
CGContextBeginPath(context);
//NSUInteger numberOfLines = (self.contentSize.height + self.bounds.size.height) / self.font.leading;
NSUInteger numberOfLines = (self.contentSize.height + self.bounds.size.height) / KLineGap;
CGFloat baselineOffset = 6.0f;
for (NSUInteger x = 1; x < numberOfLines; x++) {
//0.5f offset lines up line with pixel boundary
CGContextMoveToPoint(context, self.bounds.origin.x+10, KLineGap *x + 0.5f + baselineOffset);
CGContextAddLineToPoint(context, self.bounds.size.width-10, KLineGap *x + 0.5f + baselineOffset);
}
CGContextClosePath(context);
CGContextStrokePath(context);
}
截图: