Tag: uiappearance

自定义容器控制器:transitionFromViewController:视图在animation之前未正确放置

这既是一个问题,也是一个部分的解决scheme。 *示例项目在这里: https://github.com/JosephLin/TransitionTest 问题1: 当使用transitionFromViewController:… , toViewController的viewWillAppear:完成的布局viewWillAppear:当过渡animation开始时不显示。 换句话说,布局前的视图在animation中显示,并且其内容在animation之后捕捉到布局后的位置。 问题2: 如果我自定义导航栏的UIBarButtonItem的背景,那么在animation结束之前,button会出现错误的大小/位置,并在animation结束时捕捉到正确的大小/位置,类似于问题1。 为了演示这个问题,我做了一个自定义的容器控制器,它执行一些自定义的视图转换。 这几乎是一个UINavigationController副本,交叉溶解,而不是视图之间的推animation。 'Push'方法如下所示: – (void)pushController:(UIViewController *)toViewController { UIViewController *fromViewController = [self.childViewControllers lastObject]; [self addChildViewController:toViewController]; toViewController.view.frame = self.view.bounds; NSLog(@"Before transitionFromViewController:"); [self transitionFromViewController:fromViewController toViewController:toViewController duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{} completion:^(BOOL finished) { [toViewController didMoveToParentViewController:self]; }]; } 现在, DetailViewController (我推动的视图控制器)需要在viewWillAppear:布局其内容。 它不能在viewDidLoad因为那时候没有正确的框架。 为了演示目的, DetailViewController将其标签设置为viewDidLoad , viewWillAppear和viewDidAppear不同位置和颜色: – (void)viewDidLoad { [super viewDidLoad]; […]

如何使UIAppearance代理适用于编程创build的意见?

我试图使用UIAppearance来为我的应用程序创build一个主题。 说我想我所有的UILabel的文本是橙色的。 我写了: UILabel.appearance(whenContainedInInstancesOf: [UIView.self]).textColor = .orange 但是我意识到: 这适用于通过Interface Builder创build的每个UILabel 。 这不适用于以编程方式创build的任何UILabel 。 它们默认显示为黑色 任何想法如何强制以编程方式创build的实例也是橙色的? PS:我也试过: UILabel.appearance().textColor = .green这不是我想要的,但也不起作用。

setSelectedImageTintColor在iOS 7中不起作用

我想在iOS 7中设置setSelectedImageTintColor ,但它不工作。 这是我在我的AppDelegate.m下的didFinishLaunchingWithOptions的代码 UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController; UITabBar *tabBar = tabBarController.tabBar; for (UITabBarItem *item in tabBar.items) { UIImage *image = item.image; UIImage *correctImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; item.image = correctImage; } [[UITabBar appearance] setTintColor:[UIColor whiteColor]]; [[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:44.0/255.0 green:176.0/255.0 blue:28.0/255.0 alpha:1.0]]; [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0]]; 它仍然不会显示selectedImageTintColor。 选中时是白色的; 灰色时,未选中。 我究竟做错了什么?

如何在iOS 8中通过外观代理设置UIButton字体?

我试图通过外观代理设置UIButton的字体。 但似乎没有工作。 这是我的尝试。 UIButton.appearance().titleFont = UIFont(name: FONT_NAME_DEFAULT, size:20.0) UIButton.appearance().titleLabel?.font = UIFont(name: FONT_NAME_DEFAULT, size:20.0) 如何在iOS 8中通过外观代理设置UIButton字体? 编辑 :在vaberer的链接中find:“我很惊讶,UIButton没有任何UI_APPEARANCE_SELECTOR属性,但符合UIAppearance协议。

UINavigationBar自iOS6以来未alignment的标题

自从iOS 6以来,我在我的应用程序中使用自定义样式有几个问题。 我使用自定义字体和几个UIAppearance代理。 我无法理解的问题是UINavigationBar中标题的错位。 在iOS 5中一切正常,并正确alignment。 由于iOS6已经发布,自定义样式并不less见,我认为这不是一个错误,但我误解了对iOS6的一些新变化。 我已经search了一个文本alignment方法来调用UIAppearance代理的文档,但我无法find这样的方法。 我使用下面的代码行来在我的整个应用程序中设置我的UINavigationBar: [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"] forBarMetrics:UIBarMetricsLandscapePhone]; [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, [UIFont fontWithName:@"Corbel-Bold" size:14.0], UITextAttributeFont, nil]]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor ceBlueColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"Corbel" […]

自定义后退button出现在UIImagePickerController上

我使用下面的代码来定制我的应用程序中导航栏上的后退button: UIImage *backButton = [[UIImage imageNamed:@"backButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; UIImage *backButtonOn = [[UIImage imageNamed:@"backButton_on"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonOn forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; 除了当我提供一个UIImagePickerController,并在照片库中input一个相册的后退button也是自定义后退button,它工作得很好。 如何取回图像select器中的原始后退button?

UINavigationBar外观模式不设置

我在我的appDelegate中使用下面的代码来设置我的UINavigationBar和状态栏在我的应用程序的外观: [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 除非第三方模式viewController被阻止,例如Dropbox API或UIActivityViewController的邮件/消息viewController,否则此代码正确地将所有内容的外观设置为白色。 我已经包含了一些截图,以显示这些如何看。 UIActivityViewController邮件: UIActivityViewController消息: Dropbox API: 我试图把这个 [[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; 以及 [[UINavigationBar appearanceWhenContainedIn:[UIActivityViewController class], nil] setTintColor:[UIColor whiteColor]]; 没有一个在工作。

在Swift中定制UIBarButtonItem

我试图在AppDelegate设置UIBarButtonItem的字体,如下UIBarButtonItem : let barButton = UIBarButtonItem.appearance() barButton.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "AvenirNext", size: 15], forState: UIControlState.Normal) 但它引发了一个编译器错误说: Cannot invoke 'init' with an argument list type '($T7, forState: UIControlState) 我不知道这意味着什么 我也试过了 barButton.titleTextAttributesForState(UIControlState.Normal) =[NSFontAttributeName…] 但似乎是不可转让的 我该怎么做? 非常感谢!

我可以检测iOS的“变暗的颜色”设置?

我注意到,当启用“暗色”iOS系统设置时,我的应用程序看起来不太好。 有些导航button是白色的,有些则变成灰色。 有没有办法检测这个设置是否被启用?

使用UIAppearance自定义UIBarButtonItem“完成”样式和“简单”样式

我知道如何使用-setBackgroundImage: forState: barMetrics:来自定义UIBarButtonItem ,但是我想为UIBarButtonItemStyleDone和UIBarButtonItemStylePlain使用不同的图像。 有没有办法使用UIAppearance协议来完成这个UIAppearance ? 或者我每次需要“完成”样式button时都必须设置图像? (我试图用下面的代码搞乱: [[UIBarButtonItem appearance] setBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarButtonItemStyleDone]; 但是,这只是用“完成”图像设置每个栏button。) 谢谢!