How to iOS item and font sizes scaling as screen size

前端 未结 3 857
暖寄归人
暖寄归人 2020-12-04 03:36

I want to make item and font sizes looking same as screen sizes. I used to use item ratio for scaling to handle different iOS screen but there was problem with item\'s size

3条回答
  •  心在旅途
    2020-12-04 04:25

    Try this code :-

       struct fontSizeConstant{
    
            static let relativeFontConstant : CGFloat = 0.015
            static let bigFontConst : CGFloat = 0.050
            static let lessBigFontConst : CGFloat = 0.040
            static let mediumFontConst : CGFloat = 0.030
        }
    userName.font = userName.font?.withSize(self.view.frame.height * fontSizeConstant.mediumFontConst)
    
                password.font = password.font?.withSize(self.view.frame.height * fontSizeConstant.mediumFontConst)
    
                loginButton.titleLabel?.font = loginButton.titleLabel?.font.withSize(self.view.frame.height * fontSizeConstant.lessBigFontConst)
    

提交回复
热议问题