iOS 10 can no longer set barcolor and tint on MFMessageComposeViewController

后端 未结 4 558
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 01:50

Below code works on iOS version 9.x or less, for some reason this does not work if iOS 10

 if([MFMessageComposeViewController canSendText])
             {
               


        
4条回答
  •  鱼传尺愫
    2021-02-04 02:51

    Objective-C solution:

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor redColor]] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
    [[UINavigationBar appearance] setTintColor:[UIColor redColor]];
    

    Image with color method:

    + (UIImage *)imageWithColor:(UIColor *)paramColor
    {
        CGRect frame = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
        UIGraphicsBeginImageContextWithOptions(frame.size, NO, [UIScreen mainScreen].scale);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    
        CGContextSetFillColorWithColor(context, [paramColor CGColor]);
        CGContextFillRect(context, frame);
    
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return image;
    }
    

提交回复
热议问题