xcode - Different font sizes for uibutton and uilabel for iphone/ipad -


i working on quiz game,it started iphone app,now working , want make universal app,but can't find way set font size 1 value iphones , ipad

i tried auto shrink menu in interface builder,but works labels,and if same via code uibutton code doesn't work,this code wrote inside viewdidload

ans2b.titlelabel?.numberoflines = 1 ans2b.titlelabel?.adjustsfontsizetofitwidth = true ans2b.titlelabel?.minimumscalefactor = 2 

for label used interface builder , works labels changes font size every time text inside changes

how can put value font size iphones , value ipads?can interface builder or via code? maybe can put value in interface builder , condition in viewdidload change size if device ipad

thanks

you can check device type.

if (uidevice.currentdevice().userinterfaceidiom == uiuserinterfaceidiom.pad)     {         //label font size ipad     }     else     {         //label font size iphones     } 

we have enum define device type check.

    enum uiuserinterfaceidiom : int {     case unspecified     case phone // iphone , ipod touch style ui     case pad // ipad style ui } 

Comments