我正在编写一个调整来更改控制中心的大小。
我正在尝试根据方向设置框架。
这是代码:
%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 语句设置的内容设置框架。我做错了什么,还有其他选择吗?