From fd66eeeae62690669d204ac78bce7db887db5d41 Mon Sep 17 00:00:00 2001 From: soushi Date: Mon, 2 Mar 2026 14:53:12 +0900 Subject: [PATCH] Replace deprecated UIBarMetricsLandscapePhone with UIBarMetricsCompact Migrated legacy UIBarMetricsLandscapePhone to UIBarMetricsCompact as per iOS 8+ API recommendations. Removed incorrect bitwise AND operation and explicitly set background images for both default and compact bar metrics. Resolved -Wdeprecated-declarations warnings to align with modern UIKit standards. --- Classes/ios/UIBarButtonItem+FlatUI.m | 10 +++++----- Classes/ios/UINavigationBar+FlatUI.m | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Classes/ios/UIBarButtonItem+FlatUI.m b/Classes/ios/UIBarButtonItem+FlatUI.m index fa13521..781c5d5 100644 --- a/Classes/ios/UIBarButtonItem+FlatUI.m +++ b/Classes/ios/UIBarButtonItem+FlatUI.m @@ -70,10 +70,10 @@ + (void) configureItemOrProxy:(id)appearance barMetrics:UIBarMetricsDefault cornerRadius:cornerRadius]; UIImage *backButtonLandscapeImage = [UIImage backButtonImageWithColor:color - barMetrics:UIBarMetricsLandscapePhone + barMetrics:UIBarMetricsCompact cornerRadius:2]; UIImage *highlightedBackButtonLandscapeImage = [UIImage backButtonImageWithColor:highlightedColor - barMetrics:UIBarMetricsLandscapePhone + barMetrics:UIBarMetricsCompact cornerRadius:2]; [appearance setBackButtonBackgroundImage:backButtonPortraitImage @@ -81,16 +81,16 @@ + (void) configureItemOrProxy:(id)appearance barMetrics:UIBarMetricsDefault]; [appearance setBackButtonBackgroundImage:backButtonLandscapeImage forState:UIControlStateNormal - barMetrics:UIBarMetricsLandscapePhone]; + barMetrics:UIBarMetricsCompact]; [appearance setBackButtonBackgroundImage:highlightedBackButtonPortraitImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; [appearance setBackButtonBackgroundImage:highlightedBackButtonLandscapeImage forState:UIControlStateHighlighted - barMetrics:UIBarMetricsLandscapePhone]; + barMetrics:UIBarMetricsCompact]; [appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsDefault]; - [appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsLandscapePhone]; + [appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsCompact]; UIImage *buttonImageNormal = [UIImage imageWithColor:color cornerRadius:cornerRadius]; UIImage *buttonImageHightlighted = [UIImage imageWithColor:highlightedColor cornerRadius:cornerRadius]; diff --git a/Classes/ios/UINavigationBar+FlatUI.m b/Classes/ios/UINavigationBar+FlatUI.m index dbf4bb4..1b7223f 100644 --- a/Classes/ios/UINavigationBar+FlatUI.m +++ b/Classes/ios/UINavigationBar+FlatUI.m @@ -13,7 +13,9 @@ @implementation UINavigationBar (FlatUI) - (void) configureFlatNavigationBarWithColor:(UIColor *)color { [self setBackgroundImage:[UIImage imageWithColor:color cornerRadius:0] - forBarMetrics:UIBarMetricsDefault & UIBarMetricsLandscapePhone]; + forBarMetrics:UIBarMetricsDefault]; + [self setBackgroundImage:[UIImage imageWithColor:color cornerRadius:0] + forBarMetrics:UIBarMetricsCompact]; NSMutableDictionary *titleTextAttributes = [[self titleTextAttributes] mutableCopy]; if (!titleTextAttributes) { titleTextAttributes = [NSMutableDictionary dictionary];