1

I'm using iOS 15 with Xcode 13.0, and I have encountered a known problem whit the navigation bar due to UIKit which has extended the usage of the scrollEdgeAppearance. So I solved the issue using this answer iOS 15 Navigation Bar Transparent .

Now I have another problem. I have to set the background color of the navigation bar to have a gradient color, from the starColor to the endColor.

This is the situation in iOS 15: enter image description here and iOS 14.6: enter image description here

Now I want it to work in iOS 15 as it did in iOS 14.8.

This is the code that I added in application:didFinishLaunchingWithOptions:, based on the solutions found on stackoverflow:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

if (@available(iOS 15, *)){
    UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
    [appearance configureWithTransparentBackground];
    [appearance setBackgroundColor:startColor];
    [UINavigationBar appearance].standardAppearance = appearance;
    [UINavigationBar appearance].scrollEdgeAppearance = appearance;
} }

I want to change the line [appearance setBackgroundColor:startColor] in order to have a gradient background (from startColor to endColor). How can I achieve that?

Thanks

0 Answers0