在我的AppDelegate中,我使用UIAppearance使用以下代码设置我自己的NavigationBar:
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav5.png"] forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
但是我的应用程序的一些视图不需要它.我怎样才能摆脱它,所以我只能在相关的观点中使用IB?
我有一个外观代理,将barTintColor属性设置为绿色UINavigationBar
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:54./255 green:165./255 blue:53./255 alpha:1]];
根据需要,我使用覆盖它 appearanceWhenContainedIn:
[[UINavigationBar appearanceWhenContainedIn:[INFSearchViewController class], nil] setBarTintColor:[UIColor colorWithWhite:0.80 alpha:1]];
这很好用.
但是,当我提出MFMessageComposeViewController它遵守UINavigationBar代理时,看起来如下所示.

这显然看起来很糟糕,我宁愿MFMessageComposeViewController不坚持代理,但试图做
[[UINavigationBar appearanceWhenContainedIn:[MFMessageComposeViewController class], nil] setBarTintColor:[UIColor whiteColor]];
没有影响.
我应该采取什么行动?
通过设置具有外观的a 的Titlecolor,a 中的a 得到相同的颜色.UIButtonUIMenuItemsUIMenuControllerUITextView
applicationDidFinishLaunching:[[UIButton appearance] setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
有没有办法抑制它
或
给UIMenuItems另一种颜色?
withWhenContainedIn UITextview
我试图设置TextViews中包含的按钮的外观
[UIButton appearanceWhenContainedIn:[UITextView class], nil]
但是这显然不起作用,因为UIMenuController它不在TextView中.
使用appearanceWhenContainedIn UIMenuController/UIMenuItem
是不可能的,因为两者都没有实现UIAppearanceContainer协议.
有没有办法在保持UIViewControllerBasedStatusBarAppearance启用的同时设置默认状态栏样式?
这是问题,我正在处理:
UIStatusBarStyle.LightContent由于导航栏背景较暗,因此几乎需要使用整个应用程序.最初,UIViewControllerBasedStatusBarAppearance被禁用,并且Info.plist在文本状态状态栏中设置了以下内容:
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
Run Code Online (Sandbox Code Playgroud)
这工作得很好,直到我发现这个.LightContent状态栏甚至显示为某些共享扩展,如Facebook Messenger,导致它不可读:
这可以通过使用来解决UIViewControllerBasedStatusBarAppearance,但是我需要将以下方法添加到我想要避免的所有视图控制器中,因为应用程序非常大.
此外,对于具有轻型导航栏背景的应用程序中的一个屏幕,我使用UIApplication.sharedApplication().setStatusBarStyle()但是在iOS 9中不推荐使用此方法.
任何想法如何解决这个问题?混写?
我想要一个没有标题的后退按钮,但我不能让它工作.我在目标方面真的很新......
UIImage *backButtonImage = [[UIImage imageNamed:@"back.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 30, 50)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
使用该代码我有我的后退按钮,但也有上一页的标题.
我找到了一些使用UIViewController类的工作示例,但在我的例子中,代码位于appDelegate.m文件中.
知道如何让它工作吗?
我想创建一个像这样的分隔线:

有关如何实现它的任何想法?我尝试获取该行的图像并使用UIAppearance代理对象:
[[UITableView appearanceWhenContainedIn:[MyController class], nil] setSeparatorColor:
[UIColor colorWithPatternImage:[UIImage imageNamed:@"line.png"]]];
[[UITableView appearanceWhenContainedIn:[MyController class], nil] setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
Run Code Online (Sandbox Code Playgroud)
但是,不知何故,只有黑线被渲染.
UIKeyboardAppearanceDark用SLComposeViewController?该SLComposeViewController班提出了以用户为撰写支持社交网络服务的一个职位.
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[self presentViewController:controller
animated:YES
completion:nil];
Run Code Online (Sandbox Code Playgroud)
丑陋!
这是浅色键盘在深色背景下的外观:
小样!
这是黑暗键盘在深色背景下的外观:
我发现UISegmentedControl更改字体和大小如下:
UISegmentedControl.appearance().setTitleTextAttributes(myFontAttribute as [NSObject : AnyObject] , forState: .Normal)
但是UILabel没有这种方法
我想这样做
UILabel.appearance().setAttributed(myFontAttribute)
我不想在StoryBoard中更改UILabel字体
我想使用程序来执行此操作(因为我的应用程序已完成,但只有字体应更改为更大和其他字体)
我该怎么办 ?
我目前正在使用UIAppearance代理自定义iOS应用程序的导航栏背景图像.有一个用于在两种不同模式之间切换的按钮,用于触发通知.此通知将再次使用代理将背景更改为其他图像.我的问题是,只有当我去另一个控制器并且我回到它时,这个变化才变得可见.我无法强制更新控制器中的导航栏.
我在我的MainTabBarController中试过这个:
- (void) onAppChangedMode: (NSNotification*)notif {
APP_MODE mode = (APP_MODE) [[notif object] integerValue];
// change navigation bar appearance
[[UILabel appearance] setHighlightedTextColor:[UIColor redColor]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:(mode == 0 ? @"navbar.png" : @"navbar2.png")] forBarMetrics:UIBarMetricsDefault];
// trying to update
for (UIViewController* vc in self.viewControllers) {
[vc.navigationController.navigationBar setNeedsDisplay];
}
}
Run Code Online (Sandbox Code Playgroud)
但没什么......它不起作用.知道如何实现它吗?
谢谢!
uiappearance ×10
ios ×7
ios7 ×3
objective-c ×2
background ×1
ios5 ×1
ios7.1 ×1
mfmailcomposeviewcontroller ×1
swift ×1
uibutton ×1
uikeyboard ×1
uikit ×1
uilabel ×1
uitableview ×1
uitoolbar ×1
updates ×1
xcode ×1