2017-04-19 5 views
0

로그인이라고하는 버튼이 있습니다. 단추 글꼴 및 크기를 볼 수 있지만 단추 글꼴 크기를 볼 때 모든 장치에서 동일하게 보입니다. 어떻게 다른 장치에 대한 다른 글꼴 크기를 정의?. 나는 아이폰 초상화에 대해서만 이야기하고있다. 그래서 크기 클래스로 솔루션을 제공하지 마십시오.다른 장치의 다른 글꼴 크기를 UIButton으로 설정하십시오.

+0

는이에 대한 사이즈 클래스를 사용할 수 있습니다보십시오. – KKRocks

+1

다른 장치의 [단일 크기 클래스 내의 다른 글꼴 크기] [iOS의 가능한 복제본] (http://stackoverflow.com/questions/28076020/ios-different-font-sizes-within-single-size-class-for-different- 장치) – KKRocks

답변

0

스토리 보드에서 글꼴 크기 변형 - 글꼴 크기 정의를 사용할 수 있습니다. 아래 이미지에서 글꼴 크기를 정의하는 방법을 보여줍니다.

Font 속성 외에 작은 + 버튼을

enter image description here

클릭, 팝 업이 나타납니다.

위 그림에서와 같이 다양한 변형에 대해 WidthHeight의 크기를 정의 할 수 있습니다.

0

iPhone 장치 크기를 확인한 다음 if-else 루프에서 단추 글꼴 크기 논리를 적용 할 수 있습니다.

#define iPhoneVersion ([[UIScreen mainScreen] bounds].size.height == 568 ? 5 : ([[UIScreen mainScreen] bounds].size.height == 480 ? 4 : ([[UIScreen mainScreen] bounds].size.height == 667 ? 6 : ([[UIScreen mainScreen] bounds].size.height == 736 ? 7 : ([[UIScreen mainScreen] bounds].size.height == 736 ? 61 : ([[UIScreen mainScreen] bounds].size.height == 736 ? 61 : (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 10 :61))))))) 

if (iPhoneVersion == 4) 
{ 
    mybutton.titleLabel.font = [UIFont systemFontOfSize:12]; 
} 
else if (iPhoneVersion == 5) 
{ 
    mybutton.titleLabel.font = [UIFont systemFontOfSize:14]; 
} 
else if (iPhoneVersion == 6) 
{ 
    mybutton.titleLabel.font = [UIFont systemFontOfSize:16]; 
} 
else if (iPhoneVersion == 7) 
{ 
    mybutton.titleLabel.font = [UIFont systemFontOfSize:17]; 
} 

및 모든 장치가 동일합니다.

0

if UIScreen.mainScreen().bounds.size.height == 480 { 
    // iPhone 4 
    mybutton.titleLabel.font = mybutton.titleLabel.font.fontWithSize(20)  
} else if UIScreen.mainScreen().bounds.size.height == 568 { 
    // IPhone 5 
    mybutton.titleLabel.fontt = mybutton.titleLabel.font.fontWithSize(20) 
} else if UIScreen.mainScreen().bounds.size.width == 375 { 
    // iPhone 6 
    mybutton.titleLabel.font = mybutton.titleLabel.font.fontWithSize(20) 
} else if UIScreen.mainScreen().bounds.size.width == 414 { 
    // iPhone 6+ 
    mybutton.titleLabel.font = mybutton.titleLabel.font.fontWithSize(20) 
} else if UIScreen.mainScreen().bounds.size.width == 768 { 
    // iPad 
    mybutton.titleLabel.font = mybutton.titleLabel.font.fontWithSize(20) 
} 
관련 문제