EGO TextView中的线高

时间:2012-11-12 07:50:55

标签: iphone ios uitextview core-text css

我使用EGOTextView进行富文本编辑。但是lineHeight的{​​{1}}似乎比EGOTextView中的UITextView略小,它们设置为相同的字体。 我试图在默认属性中设置kCTParagraphStyleSpecifierMinimumLineHeightkCTParagraphStyleSpecifierMaximumLineHeight,但这不是一个好的解决方案,因为我需要插入必须修改lineHeight的图像。任何帮助将不胜感激:)

enter image description here enter image description here

EGOTextView.m

- (void)viewDidLoad {
[super viewDidLoad];
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"UITextView", @"EGOTextView", nil]];
segment.segmentedControlStyle = UISegmentedControlStyleBar;
[segment addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = segment;
[segment release];

if (_textView==nil) {
    UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
    textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    textView.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:textView];
    self.textView = textView;
    [textView release];
}

if (_egoTextView==nil) {
    EGOTextView *view = [[EGOTextView alloc] initWithFrame:self.view.bounds];
    view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    view.delegate = (id<EGOTextViewDelegate>)self;
    [self.view addSubview:view];
    self.egoTextView = view;
    self.egoTextView.delegate = self;
    [view release];  
    [self.egoTextView setFont:[UIFont systemFontOfSize:14]];
}
[segment setSelectedSegmentIndex:1];
}

1 个答案:

答案 0 :(得分:1)

您可以将kCTParagraphStyleSpecifierLineSpacing CTParagraphStyleSetting的{​​{1}}设置为您想要分隔线的点数。或者,您也可以使用NSAttributedString指定行高多个,以便将行高增加一个因子。

这是一个简单的例子:

kCTParagraphStyleSpecifierLineHeightMultiple