2017-02-14 1 views
1

텍스트 크기와 버튼은 아이폰 7과 아이폰 6에 잘 보이지만, 아이폰 5S 또는 아이폰에서 실행 중일 때 크기는 동일하게 유지 5.글꼴 크기 및 UIView의 크기가 4S는 아이폰 6, 아이폰 5S에 대한 동일

하는 경우 나는 15 점의 왼쪽 공간 제약 조건을 제공하지만, iPhone 7에서는 정말 좋게 보이지만, iPhone 5에서는 너무 많은 공간을 제공합니다.

모든 장치 제품군에 대해 동적보기 및 FontSize를 구현하는 방법입니다. 당신이 사용자 자동 레이아웃 수에 대해 사전

+0

설정 전에 시도한 것을 보여줄 수 있습니까? See [Ask] –

답변

0

에서

감사합니다. 보기를 수퍼 뷰의 여백에 제한하면됩니다. 나는.

yourView -> superView.Leading.Margin 
yourView -> superView.Trailing.Margin 

보기 컨트롤러의 여백을 사용하면 모든 장치에서 제대로 작동하는지 확인할 수 있습니다.

글꼴 크기 - Apple은 거의 모든 상황에서 사용할 수있는 'prefferedFontStyles'라는 것을 제공합니다. 그래서 당신은 당신의 버튼을 그냥 모든 장치에 일반 찾고 텍스트 크기를 가지고 싶다면, 간단하게 다음을 수행하십시오를 얻을하는 데 도움이

yourLabel.font = UIFont.preferredBody 

또는

UIFont.preferredTitle 

등 등

희망 그것의 교수형

0

예를 들어, UIFont.systemFont(ofSize: 16)은 4.7 "iPhone (화면 폭이 375pt 인 경우)에 좋지만 작은 장치에서는 너무 큽니다. 글꼴 크기를 조정 해보십시오. 화면 폭에 에드 ... 인 세트 들어

let fontSize = UIScreen.main.bounds.width/375 * 16 
let font = UIFont.systemFont(ofSize: fontSize) 

이 @FlorensvonBuchwaldt 당, 자동 레이아웃이 그것에 UILabel 것 수퍼의 여백을 제한하는 사용 후 조정 삽입에 layoutMargins ...

let margin = UIScreen.main.bounds.width/375 * 15 
myView.layoutMargins = UIEdgeInsets(top: margin, left: margin, bottom: margin, right: margin) 
0
// create global width ratio constant and use it when your need 
let _widthRatio : CGFloat = { 
    let ratio = _screenSize.width/375 
    return ratio 
}() 

//use constant 
let font = UIFont.systemFont(ofSize: fontSize * _widthRatio) 

// if you set font from storyboard then create subclass of your control 
class YMWidthLabel: UILabel { 
    override func awakeFromNib() { 
     super.awakeFromNib() 
     font = font.withSize(font.pointSize * _widthRatio) 
    } 
} 

// Now bind YMWidthLabel class in storyboard 
관련 문제