Scale text label by screen size

前端 未结 7 1343
长情又很酷
长情又很酷 2020-12-08 10:13

Is there a way to scale text so that it takes up close to the same screen real estate no matter what the device size is? I\'ve found that the text on an iPad sized device is

7条回答
  •  清歌不尽
    2020-12-08 10:56

    different screen sizes acoording to

    // iphone 5s,SE screen width 320
    // iphone 6,6s,7,etc width 375
    // iphone 7 plus, 8 plus, xs max,etc width 414
    if (self.view.frame.width == 320) {
    
        label.font = UIFont(name: label.font.fontName, size: 16)
    
    } else if (self.view.frame.width == 375) {
    
        label.font = UIFont(name: label.font.fontName, size: 21)
    
    } else if (self.view.frame.width == 414) {
    
        label.font = UIFont(name: label.font.fontName, size: 24)
    
    }
    

提交回复
热议问题