1

行間にスペースを追加することに頭を悩ませています。誰かが何をする必要があるかを教えてくれれば、それは本当に役に立ちます。

NSMutableParagraphStyleを使用すると、この問題を修正できますが、展開ターゲットは ios5 です。そのため、NSMutableParagraphStyle はサポートされていません。

フォントサイズ: 18 行間 30

コード:

CustomNote.h

@interface CustomNote : UITextView<UIScrollViewDelegate,
    UITextViewDelegate>{ } @end

CustomNote.m

@implementation カスタムノート

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

スクリーンショット:

ここに画像の説明を入力

4

0 に答える 0