내 StoryBoard
은 iPhone4 해상도 용으로 구성되어 있으며 iPhone 5에서 실행 중일 때 UIView가 커질 수 있습니다 (두 높이 모두 & 너비가 됨).비례를 유지하면서 iPhone 5 화면에 맞도록 UI 크기 자동 조절
지금 문제는 이 더 높아지고 넓어지지 않는다는 것입니다.. 이를 달성하기 위해 자동 크기 조정 구성은 무엇이되어야합니까?
내 StoryBoard
은 iPhone4 해상도 용으로 구성되어 있으며 iPhone 5에서 실행 중일 때 UIView가 커질 수 있습니다 (두 높이 모두 & 너비가 됨).비례를 유지하면서 iPhone 5 화면에 맞도록 UI 크기 자동 조절
지금 문제는 이 더 높아지고 넓어지지 않는다는 것입니다.. 이를 달성하기 위해 자동 크기 조정 구성은 무엇이되어야합니까?
당신은 아마 프레임 변경을 잡으려고 재정의
setFrame:
방법
UIView
의 서브 클래스를 사용해야합니다.
- (void)setFrame:(CGRect)frame
{
frame.size.width = frame.size.height; // Make the *width* always equal to the *height*. Logic could go here, etc.
[super setFrame:frame]
}
화면의 높이를 참조하고 패딩 값을 사용하여 뷰 프레임을 설정하십시오. 다음은 yourShapeView
이라는 UIView의 프레임을 설정하는 코드입니다.
// Get the frame of the screen
CGRect screenFrame = [[UIScreen mainScreen] bounds];
// Set padding from the top and bottom of the shape
CGFloat verticalPadding = 40.0f;
CGFloat horizontalPadding = 20.0f;
// Get the height/width values
CGFloat height = screenFrame.size.height - (verticalPadding * 2);
CGFloat width = screenFrame.size.width - (horizontalPadding * 2);
// Set the size of your shape based on the height and padding
yourShapeView.frame = CGRectMake(horizontalPadding, verticalPadding, width, height);
자동 레이아웃 사용 (떨림)? – Undo
In에서는 iOS5에서도 작업해야하므로 자동 레이아웃은 옵션이 아닙니다. – Rizon
흠 ... 하위 클래스를 사용하고 코드를 작성해야하는 것처럼 보입니다. 잠깐 ... – Undo