iOS アプリのアクセシビリティ情報を表示するオーバーレイを作成する小さなライブラリに取り組んでいます。
https://github.com/SeanMcTex/SMAccessibilityOverlay
私はいくつかの優れた基本を備えていますが、UILabels を作成するときに特有の問題が発生しています。ポートレート モードのときは、すべて問題なく表示されます。
ただし、オーバーレイを横向きモードで表示すると、すべての UILabels のテキストが縦向きに合わせて回転します。
オーバーレイ ウィンドウを作成するコードは次のとおりです。
self.overlayWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.overlayWindow.windowLevel = UIWindowLevelStatusBar;
self.overlayWindow.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.75];
self.overlayWindow.rootViewController = self;
各 UILabels を作成するコードは次のとおりです。
CGRect elementFrame = [view convertRect:view.bounds toView:view.window];
UILabel *overlayElement = [[UILabel alloc] initWithFrame:elementFrame];
overlayElement.adjustsFontSizeToFitWidth = YES;
overlayElement.minimumScaleFactor = 0.5;
overlayElement.backgroundColor = [UIColor redColor];
overlayElement.textAlignment = NSTextAlignmentCenter;
overlayElement.text = view.accessibilityLabel;
[self.overlayWindow addSubview:overlayElement];
最後に、View Controller で iOS 5 および 6 用にすべての回転方法を設定しました。
# pragma mark - AutoRotation
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
しかし、オーバーレイが向きを正しく調整しているようには見えません。デバイスが開いているときにデバイスを回転させたり、ランドスケープ モードで新しいインスタンスを開いたりしても、同じ結果が得られません。
だれかが提供できるどんな助けも喜んでするべきです。前もって感謝します!