Func IsIphone6 ()Bool {ifScreenWidth () > the { return true } Else { return false}}func isiphone6plus ()-Bool {ifScreenWidth () >375 { return true } return false}func fontSize (Aview:uiview, Fivs:cgfloat, Six:cgfloat, sixplus:cgfloat) {if(Aview as? UILabel)! =Nil {ifIsiphone6plus () {(Aview asUILabel). Font =uifont.systemfontofsize (sixplus)}Else ifIsIphone6 () {(Aview asUILabel). Font =uifont.systemfontofsize (six)}Else{(Aview asUILabel). Font =uifont.systemfontofsize (Fivs)}} Else if(Aview as? UIButton)! =Nil {ifIsiphone6plus () {(Aview asUIButton). titlelabel!. Font =uifont.systemfontofsize (sixplus)}Else ifIsIphone6 () {(Aview asUIButton). titlelabel!. Font =uifont.systemfontofsize (six)}Else{(Aview asUIButton). titlelabel!. Font =uifont.systemfontofsize (Fivs) }}}
Pass in a label or button, passing in the text size of 5s,6 and 6+ quickly define text size