인터페이스 방향이 변경되는 경우에도 UIWindow
의 맨 위에 고정하고자하는 사용자 정의 UIView
이 있습니다. 여기iOS 7의 UIWindow 위에 UIView를 고정하는 방법
문제는 이전 아이폰 OS 8 UIWindow
이 방향 변경과 변경되지 않는 좌표계이다 세로 방향으로 내보기입니다. 그래서 모든 계산을 손으로해야합니다. 우선 내가 동일하게 유지 시스템을 조정 UIWindow하는 두 번째 것은 어떻게 든 실제 좌표계를 매핑하는 것이다이 방법
-(CGFloat)angleForOrientation:(UIInterfaceOrientation)orientation
{
CGFloat angle;
switch (orientation) {
case UIInterfaceOrientationLandscapeLeft:
angle = -M_PI /2.0;
NSLog(@"UIInterfaceOrientationLandscapeLeft");
break;
case UIInterfaceOrientationLandscapeRight:
angle = M_PI /2.0;
NSLog(@"UIInterfaceOrientationLandscapeRight");
break;
case UIInterfaceOrientationPortraitUpsideDown:
angle = M_PI;
NSLog(@"UIInterfaceOrientationPortraitUpsideDown");
break;
default:
angle = 0;
NSLog(@"UIInterfaceOrientationPortrait");
break;
}
return angle;
}
를 사용하여 않는의 UIView
의 변환을 변경하는 것입니다. 그러면 사용자가 다른 방향으로보기를 회전해도 화면의 가운데 중앙에 고정 된 동일한 크기의 UIView를 갖게되는 사용자 정의 프레임 UIView
을 어떻게 계산해야합니까? 는 예를 들어이 뷰가이 이미지는 아이폰 OS 8 버전에서 생성되는 그런데 풍경
에 같이하는 방법입니다. 어떤 작업을 수행합니까?
self.frame = CGRectMake(window.bounds.size/2-50, 0, 100, 100);
CGFloat angle = [self angleForOrientation:orientation];
self.transform = CGAffineTransformMakeRotation(angle);
iOS 7과 비슷한 작업을 수행해야합니다. 어떻게해야합니까?
도움 주셔서 감사합니다.
이 프로젝트에서 그 코드 https://github.com/hfossli/AGWindowView – Andrea
감사 안드레아 살펴보십시오합니다 (변환을 처리하는 방법을보고 내 질문 참조). 그것이 내가 시도한 첫 번째 것이었지만 그것은 나의 경우를 해결하지 못했습니다. 소스 코드를 수정해야 할 수도 있습니다. – kyurkchyan