NSCoder
NSCoder

Reputation: 245

how to access _statusBar from UIApplication

Reading through UIApplication.h, there is a property

@interface UIApplication : UIResponder <FBSUIApplicationWorkspaceDelegate, FBSSceneDelegate, FBSUIApplicationSystemServiceDelegate, NSUserActivityDelegate, UIActionSheetDelegate> {

    id<UIApplicationDelegate> _delegate;
    NSMutableSet* _exclusiveTouchWindows;
    ......
    UIStatusBar* _statusBar;
}

In my code, I tried to use both [UIApplication sharedApplication].statusBar and [[UIApplication sharedApplication] getStatusBar]

but got Xcode errors that the property is not found in first case and no selector for getStatusBar. Then further down the header file, there is declaration for properties and methods (selectors).

I thought these in parentheses are properties. If I were to access these attributes in the parentheses, how do I do it?

Upvotes: 0

Views: 63

Answers (1)

Nicolas Buquet
Nicolas Buquet

Reputation: 3955

You can access it by C programming style:

[UIApplication sharedApplication]->_statusBar

But it is defined under @package directive which means it should not be accessed like this (and your app risks to be rejected if submitted to Apple with this access).

But you can use:

[UIApplication sharedApplication].statusBarFrame
[UIApplication sharedApplication].statusBarStyle
[UIApplication sharedApplication].statusBarHidden
[UIApplication sharedApplication].statusBarOrientation
[UIApplication sharedApplication].statusBarOrientationAnimationDuration

Upvotes: 2

Related Questions