2016-02-20 47 views
0

我的应用程序使用下面的这一行来更改所有按钮以使用此特定颜色。它也将我的SFSafariViewController中的按钮变成看起来很糟糕的相同颜色。但是我找不到解决这个问题的好方法。我做的唯一方法就是下面的代码,但是之后有一个问题。使用全局应用程序颜色的SFSafariViewController背景按钮颜色

[[UIButton appearance] setBackgroundColor:[Helper getColor:self.application.color]]; 

因为setBackgroundColor工作,但是一旦我完成了浏览器并返回到应用程序,我的所有按钮都清除了。

[[UIButton appearance] setBackgroundColor:[UIColor clearColor]]; 
     SFSafariViewController *safariViewController = [[SFSafariViewController alloc]initWithURL:[NSURL URLWithString:self.message.filePath]]; 
     [self presentViewController:safariViewController animated:true completion:nil]; 

这也没有工作。

[[UIButton appearanceWhenContainedIn:[SFSafariViewController class], nil] setBackgroundColor:[UIColor clearColor]]; 

必须有一个更简单的方法来做到这一点。您可以在Safari浏览器中看到应用程序的颜色为橙色,并且看起来不太好。

enter image description here

回答

0

看起来像做是创建一个自定义视图控制器和跟踪前一色的唯一途径。

@implementation BrowserViewController 

@synthesize appColor; 

-(instancetype)initWithURL:(NSURL *)URL { 
    appColor = [[UIButton appearance] backgroundColor]; 
    [[UIButton appearance] setBackgroundColor:[UIColor clearColor]]; 
    return [super initWithURL: URL]; 

} 

- (void)viewWillDisappear:(BOOL)animated { 
    [[UIButton appearance] setBackgroundColor:appColor]; 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidUnload { 

    self.appColor = nil; 

    [super viewDidUnload]; 
} 



@end