【问题标题】:How can I change tint color of UIBarButtonItem while using FBSDK share dialog如何在使用 FBSDK 共享对话框时更改 UIBarButtonItem 的色调颜色
【发布时间】:2017-02-27 11:28:29
【问题描述】:

我遇到了 UIBarButtonItem tintColor 的问题。

我在 AppDelegate 中设置了[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]]; 以在应用中使用默认颜色

但是在这个屏幕上。它似乎看不到按钮,因为它是白色的! 我使用FBSDKShareDialog showFromViewController 显示共享弹出屏幕。如何编辑此屏幕的 tintColor?

编辑以解释更多。

作为建议,它仅适用于此屏幕。但实际上我的问题是在我将此屏幕更改为蓝色之后。它将影响发送电子邮件屏幕。所以在电子邮件屏幕中似乎也看不到按钮,因为我的导航栏是蓝色的。那是骗人的。我使用 UIActicityController 来呈现电子邮件屏幕。

【问题讨论】:

  • 更改 appdelegate 文件中的代码 if([UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) { [UINavigationBar appearance].tintColor = [UIColor whiteColor]; }
  • @Jigar 我必须设置[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];,因为当用户点击发送到电子邮件时。按钮将默认设置为蓝色,我的导航栏颜色也是蓝色。所以它不会像这个按钮一样看到

标签: ios objective-c uinavigationbar uibarbuttonitem fbsdk


【解决方案1】:

目标c

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

- (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
}

【讨论】:

  • 对不起,您的建议可以改变 tintColor 但我解释了更多有问题的信息。所以这行不通
【解决方案2】:

如果你还没有弄清楚这一点,你可以做的是使用FBSDKSharing的代表。

- (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
{
}

【讨论】:

    猜你喜欢
    • 2022-01-17
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    相关资源
    最近更新 更多