Swift 优雅的适配大小

栏目: Swift · 发布时间: 5年前

内容简介:使用Cocoapods安装,或手动拖入项目下面列出一些设备对应的分辨率,方便查找

使用Cocoapods安装,或手动拖入项目

pod 'SwiftyFitsize'
复制代码

使用

SwiftyFitsize 在默认状况下所使用的参照宽度为 iphone6375 如果设计图所选用设备的宽度与默认值不同,可以在 AppDelegate 下初始化所参照的宽度

SwiftyFitsize.reference(width: 414)
复制代码

下面列出一些设备对应的分辨率,方便查找

设备 逻辑分辨率(point) 设备分辨率(pixel)
SE 320x568 640x1136
6(S)/7/8 375x667 750x1334
6(S)+/7+/8+ 414x736 1080x1920
X(S) 375x812 1125x2436
XR 414x896 828x1792
XS Max 414x896 1242x2688

使用也是非常方便的,只需要在 NumberUIFontCGPointCGSizeUIEdgeInsetsMake 这些类型的值后面加上 ~ 即可

100~
UIFont.systemFont(ofSize: 14)~
CGPoint(x: 10, y: 10)~
CGSize(width: 100, height: 100)~
CGRect(x: 10, y: 10, width: 100, height: 100)~
UIEdgeInsetsMake(10, 10, 10, 10)~
复制代码

注: ~ 请不要相互嵌套使用,如

CGPoint(x: 10~, y: 10~)~
复制代码

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Security, Privacy and Commerce, 2nd Edition

Web Security, Privacy and Commerce, 2nd Edition

Simson Garfinkel / O'Reilly Media / 2002-01-15 / USD 44.95

Since the first edition of this classic reference was published, World Wide Web use has exploded and e-commerce has become a daily part of business and personal life. As Web use has grown, so have ......一起来看看 《Web Security, Privacy and Commerce, 2nd Edition》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具