• <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 设备上的字体和大小?

        How to increase fonts and sizes on plus device in Swift?(如何在 Swift 中增加 plus 设备上的字体和大小?)
          <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 设备上的字体和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                        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>
                            <tbody id='Gd4I4'></tbody>

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

                          • <small id='Gd4I4'></small><noframes id='Gd4I4'>

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