0

コントロールセンターのサイズを変更する微調整を書いています。

向きに応じてフレームを設定しようとしています。

これはコードです:

%hook SBControlCenterContainerView
-(void)layoutSubviews{
%orig;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation ]== UIDeviceOrientationLandscapeRight){
self.frame = CGRectMake(0, 0, (screenBounds.size.width - 20), 427);
} else {
self.frame = CGRectMake(0, 227, screenBounds.size.width - 20, 427);
}
}
%end

しかし、風景モードに切り替えてもフレームは変わりません。else ステートメントに設定されているものでフレームを設定するだけです。私は何を間違っていますか?

4

2 に答える 2

0

SBControlCenterContainerView の中心をその親に設定することができます。これが役に立ち、幸運を祈ります。

// In Parent UIViewController
self.sBControlCenterContainerView.center = self.view.center;
于 2016-07-20T22:44:33.100 に答える