투케이2K

63. (Objective-C/objc) UIApplication sharedApplication 사용해 앱 상태 바 (status) 사이즈 확인 및 뱃지 (badge) 알림 표시 본문

Objective-C

63. (Objective-C/objc) UIApplication sharedApplication 사용해 앱 상태 바 (status) 사이즈 확인 및 뱃지 (badge) 알림 표시

투케이2K 2022. 9. 7. 08:50
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : OBJECTIVE-C

 

[소스 코드]

// MARK: - [헤더 파일에 정의 없이 : void 메소드 구현]
- (void)testMain {
    printf("\n");
    printf("==================================== \n");
    printf("[ViewController >> testMain() :: 테스트 메소드 수행] \n");
    printf("==================================== \n");
    printf("\n");
    
    
    /*
     --------------------------------
     [UIApplication sharedApplication 설명]
     --------------------------------
     1. UIApplication sharedApplication 은 싱글톤 앱 인스턴스입니다
     --------------------------------
     2. UIApplication sharedApplication 을 사용해 앱 속성 확인 및 제어를 할 수 있습니다 (ex : 앱 뱃지 초기화)
     --------------------------------
     */
    
    
    // [디바이스 휴대폰 상태 바 높이 사이즈 확인 실시]
    double statusBarFrameHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    
    
    // [디바이스 휴대폰 상태 바 너비 사이즈 확인 실시]
    double statusBarFrameWidth = [UIApplication sharedApplication].statusBarFrame.size.width;
    
    
    // [애플리케이션 뱃지 값 지정 실시]
    [UIApplication sharedApplication].applicationIconBadgeNumber = 1;
    
    
    // [로그 출력 실시]
    printf("\n");
    printf("==================================== \n");
    printf("[ViewController >> testMain() :: 로그 결과 출력 실시] \n");
    printf("[statusBarFrameHeight :: %f] \n", statusBarFrameHeight);
    printf("[statusBarFrameWidth :: %f] \n", statusBarFrameWidth);
    printf("==================================== \n");
    printf("\n");
}
 

[결과 출력]


 

반응형
Comments