<tfoot id='xWk8d'></tfoot>
    <i id='xWk8d'><tr id='xWk8d'><dt id='xWk8d'><q id='xWk8d'><span id='xWk8d'><b id='xWk8d'><form id='xWk8d'><ins id='xWk8d'></ins><ul id='xWk8d'></ul><sub id='xWk8d'></sub></form><legend id='xWk8d'></legend><bdo id='xWk8d'><pre id='xWk8d'><center id='xWk8d'></center></pre></bdo></b><th id='xWk8d'></th></span></q></dt></tr></i><div id='xWk8d'><tfoot id='xWk8d'></tfoot><dl id='xWk8d'><fieldset id='xWk8d'></fieldset></dl></div>

    1. <legend id='xWk8d'><style id='xWk8d'><dir id='xWk8d'><q id='xWk8d'></q></dir></style></legend>

      <small id='xWk8d'></small><noframes id='xWk8d'>

        <bdo id='xWk8d'></bdo><ul id='xWk8d'></ul>
    2. 与 NSAttributedString 真的很接近吗?

      时间:2023-07-08

      <small id='i4GoI'></small><noframes id='i4GoI'>

      <i id='i4GoI'><tr id='i4GoI'><dt id='i4GoI'><q id='i4GoI'><span id='i4GoI'><b id='i4GoI'><form id='i4GoI'><ins id='i4GoI'></ins><ul id='i4GoI'></ul><sub id='i4GoI'></sub></form><legend id='i4GoI'></legend><bdo id='i4GoI'><pre id='i4GoI'><center id='i4GoI'></center></pre></bdo></b><th id='i4GoI'></th></span></q></dt></tr></i><div id='i4GoI'><tfoot id='i4GoI'></tfoot><dl id='i4GoI'><fieldset id='i4GoI'></fieldset></dl></div>

            <tbody id='i4GoI'></tbody>

            <tfoot id='i4GoI'></tfoot>
              <bdo id='i4GoI'></bdo><ul id='i4GoI'></ul>

                <legend id='i4GoI'><style id='i4GoI'><dir id='i4GoI'><q id='i4GoI'></q></dir></style></legend>
                本文介绍了与 NSAttributedString 真的很接近吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想让按钮的两行文本非常靠近(小行间距).我有以下代码:

                I want to have two lines of text appear really close together (small line spacing) for a button. I have the following code:

                NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"50 WPM"];
                
                NSMutableParagraphStyle *paragrapStyle = [[NSMutableParagraphStyle alloc] init];
                paragrapStyle.alignment = NSTextAlignmentCenter;
                paragrapStyle.lineSpacing = -10;
                
                [string addAttribute:NSParagraphStyleAttributeName value:paragrapStyle range:NSMakeRange(0, string.length)];
                
                UIFont *font1 = [UIFont systemFontOfSize:22.0];
                [string addAttribute:NSFontAttributeName value:font1 range:NSMakeRange(0, string.length - 4)];
                
                UIFont *font = [UIFont systemFontOfSize:15.0];
                [string addAttribute:NSFontAttributeName value:font range:NSMakeRange(string.length - 3, 3)];
                
                [string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0, string.length)];
                
                [self.button setAttributedTitle:string forState:UIControlStateNormal];
                

                但由于行间距不能为负数,因此它不会像我希望的那样接近.它看起来像这样:

                But as linespacing can't be negative, it doesn't get nearly as close as I'd like it to be. It looks like this:

                有什么办法可以拉近他们的距离?

                Is there any way to get them closer?

                推荐答案

                好吧,如果你有一个属性字符串,那么一切都应该是可能的.:) 你只需要看更多.

                Well if you have an attribute string then everything should be possible. :) You just have to look more.

                - (void)setMinimumLineHeight:(CGFloat)aFloat
                - (void)setMaximumLineHeight:(CGFloat)aFloat
                

                试试

                [paragraphStyle setLineSpacing:0.0f];
                [paragraphStyle setMaximumLineHeight:7.0f];
                

                你会意识到maximumLineHeight 不是maximumLineSpacing.^^

                You will realise that maximumLineHeight is not maximumLineSpacing. ^^

                例如 setMaximumLineHeight:12];

                这篇关于与 NSAttributedString 真的很接近吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:iPhone iOS如何在按钮的文本或图像下向UIButton添加线性渐变? 下一篇:如何在 iPhone 中单击 UIButton 时打开相机?

                相关文章

                • <bdo id='YWrvw'></bdo><ul id='YWrvw'></ul>
              • <tfoot id='YWrvw'></tfoot>

                <i id='YWrvw'><tr id='YWrvw'><dt id='YWrvw'><q id='YWrvw'><span id='YWrvw'><b id='YWrvw'><form id='YWrvw'><ins id='YWrvw'></ins><ul id='YWrvw'></ul><sub id='YWrvw'></sub></form><legend id='YWrvw'></legend><bdo id='YWrvw'><pre id='YWrvw'><center id='YWrvw'></center></pre></bdo></b><th id='YWrvw'></th></span></q></dt></tr></i><div id='YWrvw'><tfoot id='YWrvw'></tfoot><dl id='YWrvw'><fieldset id='YWrvw'></fieldset></dl></div>

                  <small id='YWrvw'></small><noframes id='YWrvw'>

                1. <legend id='YWrvw'><style id='YWrvw'><dir id='YWrvw'><q id='YWrvw'></q></dir></style></legend>