I know it sounds like this question has a simple answer, but hear me out. Although
Here is the relevant section of code. The line where I call the
from How do I add a subview to UIStatusBar in Theos?
UIStatusBar
is a subclass of UIView
, you can't use the addSubview
method to add a subview to it because it doesn't use it. The same goes for UIStatusBarWindow
. Neither the view or window have a viewcontroller, so I can't hook into that in any way.Here is the relevant section of code. The line where I call the
addSubviews
method on self is the issue, because addSubviews
isn't a method of UIStatusBar
.#import <CoreGraphics/CoreGraphics.h>
@interface UIStatusBar : UIView
@end
%hook UIStatusBar
- (void)layoutSubviews {
//Round corners under status bar
CGFloat radius = 15;
CGRect wholeScreen = [[UIScreen mainScreen] bounds];
UIView *roundedCorners = [[UIView alloc] initWithFrame: CGRectMake(
-radius, 20-radius, wholeScreen.size.width+2*radius, wholeScreen.size.height-20+2*radius)];
roundedCorners.layer.borderWidth = radius;
roundedCorners.layer.cornerRadius = 2*radius;
roundedCorners.layer.borderColor = UIColor.blackColor.CGColor;
roundedCorners.userInteractionEnabled = NO;
[self addSubView:roundedCorners];
}
%end
Is there another way I can add the subview? The reason I'm trying to do it this way is so that, whenever the status bar is hidden, my roundedCorners
view is also hidden. I could hide it whenever the status bar is hidden, but due to different apps using many different methods of hiding the status bar that doesn't work out as well as I hoped.from How do I add a subview to UIStatusBar in Theos?
No comments:
Post a Comment