Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. extension CGFloat {
  2. /// 结合实际硬件的尺寸,返回按比例缩放的值
  3. ///
  4. /// - Parameters:
  5. /// - designBase: 设计稿上的基值
  6. /// - realBase: 实际的基值
  7. /// - Returns: 按比例缩放后的值
  8. func scale(on designBase: CGFloat = 375, realBase: CGFloat = UIScreen.main.bounds.width) -> CGFloat {
  9. /*
  10. 设计稿按钮宽度值(self) 实际按钮宽度(return)
  11. ------------------------- = ----------------------
  12. 设计稿屏幕宽度(designBase) 实际屏幕宽度(realBase)
  13. */
  14.  
  15. let ratio = self / designBase
  16. return realBase * ratio
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement