• <small id='52P92'></small><noframes id='52P92'>

  • <legend id='52P92'><style id='52P92'><dir id='52P92'><q id='52P92'></q></dir></style></legend>
      <bdo id='52P92'></bdo><ul id='52P92'></ul>

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

        如何在 Swift 中增加 plus 设备上的字体和大小?

        时间:2023-09-09
          <tbody id='7cB2N'></tbody>

          <legend id='7cB2N'><style id='7cB2N'><dir id='7cB2N'><q id='7cB2N'></q></dir></style></legend>
        1. <small id='7cB2N'></small><noframes id='7cB2N'>

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

              1. <tfoot id='7cB2N'></tfoot>
                • <bdo id='7cB2N'></bdo><ul id='7cB2N'></ul>
                  本文介绍了如何在 Swift 中增加 plus 设备上的字体和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我观察了一些流行的应用程序.当我们比较 iPhone Plus 设备和普通设备时,字体和图像是不同的.在 iPhone Plus 设备中稍大一点.我们如何在我们的 iOS 应用程序中实现相同的目标?我已经使用了启动画面.但字体仍然相同,加号和普通设备没有区别.

                  I observed some popular apps. When we compare iPhone Plus devices and normal devices, fonts and images are varying. A little bit bigger in iPhone Plus device. How can we achieve same in our iOS applications? I already used splash screens. But still fonts are same, no difference in plus and normal devices.

                  注意:通过分辨率区分编码工作正常.但我正在寻找其他替代方式,例如自适应布局或启动屏幕.

                  Note: By resolution differentiate in coding is working fine. But I'm looking for other alternative ways like either in adaptive layouts nor launch screens.

                  推荐答案

                  只需为每个控制器创建自定义类.下面,我为 UIButton 创建 csutom 类,你也可以为其他控件创建相同的类.

                  Just create custom class for each controller. Below, I am create csutom class for UIButton, You can also create same for other control.

                  HSCustomButton.h

                  #import <UIKit/UIKit.h>
                  
                  @interface HSCustomButton : UIButton
                  
                  @end
                  

                  HSCustomButton.m

                  #import "HSCustomButton.h"
                  #define SCALE_FACTOR_H ([UIScreen mainScreen].bounds.size.height / 667) 
                  
                  
                  @implementation HSCustomButton
                  
                  - (id)initWithCoder:(NSCoder *)aDecoder {
                      if( (self = [super initWithCoder:aDecoder]) ){
                          [self layoutIfNeeded];
                          [self configurefont];
                      }
                      return self;
                  }
                  
                  - (void) configurefont {
                      CGFloat newFontSize = (self.titleLabel.font.pointSize * SCALE_FACTOR_H);
                      self.titleLabel.font = [UIFont fontWithName:self.titleLabel.font.fontName size:newFontSize];
                  }
                  @end
                  

                  只需更改故事板中的类名,然后为所有其他设备自动缩放字体.

                  Just change class name in storyboard, then font scale automatically for all other device.

                  这篇关于如何在 Swift 中增加 plus 设备上的字体和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在哪里添加 topLayoutGuide 约束代码 下一篇:NSAutoresizingMaskLayoutConstraint 的 UITableViewCell 舍入错误,但在

                  相关文章

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

                      <legend id='Gd4I4'><style id='Gd4I4'><dir id='Gd4I4'><q id='Gd4I4'></q></dir></style></legend>
                        <bdo id='Gd4I4'></bdo><ul id='Gd4I4'></ul>

                    2. <small id='Gd4I4'></small><noframes id='Gd4I4'>

                      <tfoot id='Gd4I4'></tfoot>