2017-02-27 43 views
1

我遇到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

回答

0

目標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

0

如果您還沒有想通這一個,你可以做的就是用代表們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 
{ 
} 
相關問題