1

I am breaking my head to the add more space between lines. If someone tells what need to be done, it will be really helpful.

Using NSMutableParagraphStyle this issue can fixed but deployment target is ios5.So NSMutableParagraphStyle is not supported.

Font size: 18 line gap 30

code:

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);
        }

ScreenShot:

enter image description here

Anand
  • 2,086
  • 2
  • 26
  • 44

0 Answers0