如何在使用FBSDK共享对话框时更改UIBarButtonItem的色调颜色

问题描述:

我遇到UIBarButtonItem tintColor的问题。如何在使用FBSDK共享对话框时更改UIBarButtonItem的色调颜色

我在AppDelegate中使用到默认的颜色在应用

但是在这个屏幕设置[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];。它似乎无法看到按钮,因为它是白色的! 我用FBSDKShareDialog showFromViewController来显示共享弹出屏幕。我如何编辑此屏幕的tintColor?

编辑说明更多。

作为建议,它只适用于此屏幕。但实际上我的问题是在将此屏幕更改为蓝色之后。这会影响发送电子邮件屏幕。所以在电子邮件屏幕上看起来也看不到按钮,因为我的导航栏是蓝色的。这是比较狡猾的。我使用UIActicityController来呈现电子邮件屏幕。

enter image description here

+0

变化码如果([UINavigationBar的conformsToProtocol:@protocol(UIAppearanceContainer)]){ [UINavigationBar的外观] .tintColor = [的UIColor whiteColor]; } – iOS

+0

@Jigar我必须设置[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];'因为当用户点击发送到邮件时。按钮将默认设置为蓝色,导航栏颜色也为蓝色。所以它不会看到这个按钮 – Oniikal3

目标C

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
self.window.tintColor = [UIColor whiteColor]; 
return YES; 
} 

OR

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
if([UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) { 
    [UINavigationBar appearance].tintColor = [UIColor whiteColor]; 
} 

return YES; 
} 

// ****************** ************************************************** *********

斯威夫特

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
self.window?.tintColor = UIColor.white 
return true 
} 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
if UINavigationBar is UIAppearanceContainer { 
    UINavigationBar.appearance().tintColor = UIColor.white 
} 
return true 
} 
+0

对不起,你的建议可以改变tintColor,但我解释了更多有问题的信息。所以这是行不通的 – Oniikal3

如果您还没有想通这一个,你可以做的就是用代表们FBSDKSharing。在的appdelegate文件

- (IBAction)shareOnFacebook:(id)sender 
{ 
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init]; 
    content.contentTitle = @"Content Title"; 
    content.contentURL = [NSURL URLWithString:@"https://example.com/url/to/your/app"]; 
    content.quote = @"Learn quick and simple ways for people to share content from your app or website to Facebook."; 

    // make the changes here; what you want to see in FB Dialog 
    [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; 

    FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init]; 
    dialog.fromViewController = self; 
    dialog.shareContent = content; 
    dialog.mode = FBSDKShareDialogModeShareSheet; 
    dialog.delegate = self; 
    [dialog show]; 
} 

// And change it back in these delegate methods 
-(void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results 
{ 
} 

-(void)sharerDidCancel:(id<FBSDKSharing>)sharer 
{ 
} 

-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error 
{ 
}