标签: uiappearance

iOS UIAppearance错误

我正在构建一个文件管理应用程序,在调用a UIImagePickerController或a 时偶尔会出现以下错误MPMediaPickerController:

*** -[_UIImageViewPretiledImageCacheKey hash]: message sent to deallocated instance 0x140dc0
Run Code Online (Sandbox Code Playgroud)

我最近使用iOS 5的UIAppearance API为我的应用程序提供了一个自定义主题,当我开始收到此错误时就是这样.通过猜测和检查,我发现我的代码有问题的行导致了这个错误:

UIImage *backButtonImage = [[UIImage imageNamed:@"backButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(12, 16, 12, 8)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
UIImage *barButtonImage = [[UIImage imageNamed:@"barButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(14, 12, 14, 12)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

我不知道这段代码是如何触发上述错误的.你能否向我解释一下这个错误的来源,并提供一个解决方案来解决它.

提前感谢您的帮助,Guvvy

xcode objective-c ios5 uiappearance

6
推荐指数
1
解决办法
777
查看次数

UIAppearance为UIPopoverController删除自定义NavBar背景

我正在整合iOS 5的UIAppearance功能,为我的通用应用程序提供了一个独特的主题.目前,我已在App Delegate中实现了一些代码,以便为应用程序提供自定义导航栏:

UIImage *navBarImage = [[UIImage imageNamed:@"navigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(7, 7, 7, 7)];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

这很好用,并将所有导航栏从Apple的简单样式更改为明亮的渐变.但是,我遇到的问题是它覆盖了一些我不想要它的风格.我的特殊问题是它覆盖了iPad的UIPopoverController中的导航栏背景,创造了一种丑陋的用户体验.请告诉我如何解决它.

编辑:请注意,这是一个通用应用程序,我通过iPad上的UIPopoverController和iPhone/iPod上的模态视图打开图像选择器.我只想删除iPad弹出窗口上navBar的自定义背景,而不是模态视图.

目前看起来如何: 在此输入图像描述

我希望它看起来像: 在此输入图像描述

提前感谢您的帮助,Guvvy

xcode objective-c uipopovercontroller ios5 uiappearance

6
推荐指数
1
解决办法
3018
查看次数

iOS开发人员有"主题"吗?

我知道iOS框架的概念UIAppearance允许您轻松调整应用程序中控件的视觉外观.我想知道的是,是否有任何已发布的调色板/主题库在iOS上下文中运行良好?

例如,iOS等效的jQuery Mobile主题滚轮:

http://jqueryui.com/themeroller/

(注意:我先用Google搜索过!)

iphone ipad ios uiappearance

6
推荐指数
1
解决办法
2797
查看次数

UIAppearence支持IOS 6 - 意外结果

下面的代码完全可以正常运行iOS 5,但不适用于iOS 6或更高版本.我想要的是对于电子邮件作曲家表,navigationBar图像将与其他UINavigationBar类不同.我无法理解调试指针正在响应外观方法,但在设备上它将navigationBar图像显示为"bgNavigationBar.png"; 预计是"bgNavigationBar_2.png".

请指导我.......

if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
    UIImage *logoImage44 = [[UIImage imageNamed:@"bgNavigationBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearance] setBackgroundImage:logoImage44 forBarMetrics:UIBarMetricsDefault];

    UIImage *ImagePlain = [[UIImage imageNamed:@"bgNavigationBar_2.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:ImagePlain forBarMetrics:UIBarMetricsDefault];
}
Run Code Online (Sandbox Code Playgroud)

objective-c uiappearance ios6

6
推荐指数
1
解决办法
1119
查看次数

UIAppearance删除MFMailComposeViewController的自定义导航栏背景

我在我的应用程序的导航控制器中有一个自定义的navBar图像,使用UIAppearance协议设置.但是,当通过应用程序(通过MFMailComposeViewController)发送邮件时,我想要默认的navBar而不是自定义的navBar.我尝试了这个问题中概述的方法:UIAppearance为UIPopoverController删除自定义NavBar背景,但它不起作用.我使用的代码是:

[[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

但它没有任何效果.我的应用程序是iOS 6+.这是特定的东西MFMailComposeViewController还是我错过了这个?

编辑:尝试的其他方法:

MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
mailer.navigationBar.barStyle = UIBarStyleBlack;
[self.navigationController presentViewController:mailer animated:YES completion:nil];
[mailer.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

设置UIBarStyleBlack有一些效果,因为"取消"按钮随后变为黑色,但背景图像仍然设置为旧值.

uinavigationbar ios uiappearance

6
推荐指数
1
解决办法
1454
查看次数

使用带有UIBarButtonItem子类的UIAppearance导致无法识别的选择器被发送到UINavigationButton

TL&DR;

使用UIAppearance代理设置UIBarButtonItem的子类的自定义属性会导致"无法识别的选择器"异常,因为设置器可能正由UIAppearance转发到UINavigationButton,而不是条形按钮本身.


SDK概述

我正在使用带有Xcode 5 DP5的iOS 7 Beta 5 SDK.但请不要告诉我它是在NDA之下,因为我不会在这个问题上讨论任何新功能或新类.我告诉你我的SDK,因为可以发现它只是测试版软件中的一个错误.

我做了什么

我将a子类化UIBarButtonItem并在头文件中创建了一个自定义属性:

@property (nonatomic, strong) NSString *mySubclassedProperty UI_APPEARANCE_SELECTOR;
Run Code Online (Sandbox Code Playgroud)

我的二传手和吸气器看起来像这样:

- (void)setMySubclassedProperty:(NSString *)mySubclassedProperty {
    _mySubclassedProperty = mySubclassedProperty;
    NSLog(@"%p %s %@", self, __PRETTY_FUNCTION__, mySubclassedProperty);
}
Run Code Online (Sandbox Code Playgroud)

没什么特别的,对吧?但它根本不起作用UIAppearance.当我尝试在我的应用程序的委托中设置默认外观时,它没有给我任何错误,也没有任何警告.

[[AKBarButtonItem appearance] setMySubclassedProperty:@"GLOBALLY ASSIGNED"];
Run Code Online (Sandbox Code Playgroud)

碰撞

这似乎是工作就像一个魅力,除了使用它崩溃时,我尝试设置的一个实例的事实AKBarButtonItemself.navigationItem.rightBarButtonItem:

self.navigationItem.rightBarButtonItem = [[AKBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
Run Code Online (Sandbox Code Playgroud)

回溯看起来像这样:

2013-08-13 14:30:08.551 UIBarButtonItem Subclass Demo[1512:a0b] -[UINavigationButton setMySubclassedProperty:]: unrecognized selector sent to instance 0x8c42710
2013-08-13 14:30:08.556 UIBarButtonItem Subclass Demo[1512:a0b] *** Terminating app due to uncaught …
Run Code Online (Sandbox Code Playgroud)

iphone uibarbuttonitem ios unrecognized-selector uiappearance

6
推荐指数
1
解决办法
2004
查看次数

针对不同样式的UIBarButtonItem外观代理的setTitleTextAttributes

我想用自定义字体设置我的UIBarButtonItems样式.我在UIBarButtonItem的titleTextAttributes上使用外观代理来成功完成此操作.但是,我想为不同的UIBarButtonItem样式设置不同的字体样式(即样式为"边框为中","样式完成"为"粗体").

这就是我现在正在做的事情:

  //Navigation Items


NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [UIFont myCustomLabelWithSize:18.0f], NSFontAttributeName,
                                    nil
                                    ];
  [[UIBarButtonItem appearance] setTitleTextAttributes:normalAttributes
                                              forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

如果有一个setTitleTextAttribues:forState:style,那将会是多么美妙...

如何才能完成此操作,最好还是使用外观代理?

objective-c uibarbuttonitem uibarbuttonitemstyle ios uiappearance

6
推荐指数
0
解决办法
575
查看次数

使用UIAppearance更改所有UITableViewCell的文本颜色

我无法更改UITableViewCell使用UIAppearance机制的文本颜色.

这是我的代码,其中的注释显示了什么对我有用,什么不对:

UITableViewCell *cell = [UITableViewCell appearance];
cell.backgroundColor = [UIColor blueColor]; // working
cell.textLabel.textColor = [UIColor whiteColor]; // NOT WORKING
cell.detailTextLabel.textColor = [UIColor redColor]; // NOT WORKING

UILabel *cellLabel = [UILabel appearanceWhenContainedIn:[UITableViewCell class], nil];
cellLabel.textColor = [UIColor whiteColor]; // working
Run Code Online (Sandbox Code Playgroud)

如您所见,第二种方式是工作,但我不能为普通文本和详细文本设置不同的颜色.

有什么我做错了吗?

PS在Interface Builder中静态定义东西对我来说不起作用 - 我有可以在运行时动态更改的主题.

objective-c uitableview ios uiappearance

6
推荐指数
1
解决办法
2084
查看次数

在Swift中的自定义UIView子类中通过UIAppearance设置文本属性

根据NSHipster的说法,“使自定义UI类符合UIAppearance不仅是最佳实践,而且还表明在实现过程中要加倍注意。”

因此,我正在尝试将文本属性(稍后用于创建)设置为子类中NSAttributedString的属性var titleTextAttributes: [String : AnyObject]?UIView如下所示:

func applyAppearance() {

    UINavigationBar.appearance().translucent = true
    UINavigationBar.appearance().tintColor = UIColor(named: .NavBarTextColor)
    UINavigationBar.appearance().barTintColor = UIColor(named: .NavBarBlue)
    UINavigationBar.appearance().titleTextAttributes = [
        NSForegroundColorAttributeName: UIColor(named: .NavBarTextColor),
        NSFontAttributeName: UIFont.navBarTitleFont()!
    ]

    ActionBarView.appearance().backgroundColor = UIColor(white: 1, alpha: 0.15)
    ActionBarView.appearance().titleTextAttributes = [
        NSKernAttributeName: 1.29,
        NSFontAttributeName: UIFont.buttonFont()!,
        NSForegroundColorAttributeName: UIColor.whiteColor(),
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的偷窥AppDelegate

现在,当尝试设置ActionBarView.appearance().titleTextAttributes = [ ... ]时,出现以下运行时错误:

尝试在自定义uiview子类上设置文本属性时出错

值得一提的是,在属性上设置属性UINavigationBar没有任何问题。

转到UINavigationBar的头文件将显示以下内容:

/* You may specify the font, text color, and shadow …
Run Code Online (Sandbox Code Playgroud)

uikit nsattributedstring ios uiappearance swift

6
推荐指数
2
解决办法
2518
查看次数

iOS 13 UIBarButtonItem .close ( X ) tintColor

这可能已经得到了回答,但我似乎无法找到答案。

iOS 13 引入了新的 UIBarButton.SystemItem 值.close

我已经使用了新的代理外观 API,但无论我做什么,该特定图标(带有 X 的圆圈)的背景颜色都不会从带有深灰色 X 的半透明圆圈改变。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

uibarbuttonitem tintcolor ios uiappearance ios13

6
推荐指数
1
解决办法
756
查看次数