标签: uiappearance

如何创建基于主题的应用程序?

我知道类似的问题已经被问到,但没有得到满意的答案.所以我再次添加这个问题.

基于iphone应用程序中的用户选择,我需要改变应用程序的外观(彩色字体背景图像等).有没有标准的方法来实现这一目标?

一种可能的解决方案是复制每个主题的xib文件并根据选择加载它.这是一个好方法吗?主要是因为连接出口和xib复制声音的动作是一项冗余的任务.

我想看看这个疑问的专家建议.在此先感谢您的帮助.

-mia

ios uiappearance

7
推荐指数
1
解决办法
1556
查看次数

iOS - 防止UIAppearance设置更改UIWebView输入附件视图

我的应用程序中有一个UIWebView,问题是我有一个UIAppearance来修改分段控件的外观,因此它修改了UIWebView文本字段的输入附件视图中的分段控件,我希望它看起来不错,或者不试图修改它.这是它目前的样子:

在此输入图像描述

input uiwebview uisegmentedcontrol ios uiappearance

7
推荐指数
1
解决办法
1882
查看次数

iOS - UIAppearance appearanceWhenContainedIn问题

我正在为我的导航栏设置图像,如下所示:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

然后我不希望这个图像的类,MFMessageComposeViewController所以我通过这样做排除它:

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

但它没有任何效果(导航栏仍然使用我的图像进行样式设置MFMessageComposeViewController).我在这里错过了什么?

cocoa-touch ios uiappearance

7
推荐指数
1
解决办法
3284
查看次数

Appearance API - UIBarButtonItem - MPMoviePlayerViewController和Youtube Webview

UIBarButtonItem使用Appearance API设置了如下样式

[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

这适用于整个应用程序.问题是,如果您点击一个YouTube视频,这也会改变加载的YouTube视频的视频视图中的按钮uiwebview.

YouTube示例

添加这样的代码:

[[UIBarButtonItem appearanceWhenContainedIn:[MPMoviePlayerViewController class], nil] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

不会改变任何东西(因为看起来YouTube的东西不仅仅是一个MPMoviePlayerViewController.

如果我理解正确,我也不允许更改YouTube视图的按钮(我也不想这样做).

有关如何停止在此YouTube视频观看中设置自定义栏按钮图像的任何想法?

如果您想仔细观察,参阅示例项目:https://dl.dropbox.com/u/80699/BarItemsSample.zip

iphone objective-c uinavigationbar ios5 uiappearance

7
推荐指数
2
解决办法
2309
查看次数

UINavigationBar横向标题字体大小

无论如何我可以UINavigationBar在横向模式下设置标题的字体大小吗?

我正在使用UIAppearance代理来自定义标题文本属性,而我在横向时对字体大小特别感兴趣.它是纵向字体,但在旋转到横向时,字体大小不会缩小为默认行为.

[[UINavigationBar appearance] setTitleTextAttributes:[[NSDictionary alloc] initWithObjectsAndKeys:
                                           [UIFont fontWithName:@"Awesome-Bold" size:20], UITextAttributeFont,
                                           [UIColor colorWithWhite:0.0f alpha:0.2f], UITextAttributeTextShadowColor,
                                           [NSValue valueWithUIOffset:UIOffsetMake(0.0f, -1.0f)], UITextAttributeTextShadowOffset,
                                           [UIColor whiteColor], UITextAttributeTextColor,
                                           nil]];
Run Code Online (Sandbox Code Playgroud)

不幸的是,我没有看到任何barMetric:财产setTitleAttributes:.

谢谢.

uinavigationbar uifont ios uiappearance

7
推荐指数
1
解决办法
1874
查看次数

使用UIAppearance更改后更新导航栏

我目前正在使用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)

但没什么......它不起作用.知道如何实现它吗?

谢谢!

background updates uinavigationbar ios uiappearance

7
推荐指数
3
解决办法
6007
查看次数

MKMapview影响UINavigationBar和TabBar外观

我在UIView中有一个MKMapView.iOS7之前从未出现任何问题.UITabbar和UINavigationBars的颜色由UIAppearance协议设置.

出于某种原因,无论何时启动MKMapView,我的所有标签栏和导航栏都会重置,忽略我的外观类的barTintColor设置.UIAppearance的所有其他设置似乎仍然是title属性和barItem属性.只有barTintColor会消失.

还有一件事.这只发生在iPhone 4和iPhone4S上,而不是iPhone 5上.它也不会发生在模拟器上.根本不是iOS6中的问题.

我找不到重置的其他原因.我经历了几乎关于所有事情的评论并且无论如何都没有效果.

如果我删除MKMapView控件,则不重置颜色.如果我继续使用MKMapView呈现另一个完全不同的视图,颜色将重置.

我正在寻找还有什么可以检查的想法,什么样的设置或方法可能会导致这种行为.给我一些消除的东西,我被卡住了.

附加信息:

现在想到这可能是一个错误.我在ViewDidLoad中用一行代码将导航栏的颜色硬编码为任意颜色,只是为了看看发生了什么.

UINavigationBar *bar = self.navigationController.navigationBar;
[bar setBarTintColor = [UIColor GreenColor];
Run Code Online (Sandbox Code Playgroud)

我在下一行休息了一下.检查栏,颜色似乎设置.

在iPhone4或4S上,条形不会变为绿色.在iPhone5和模拟器上,条形变为绿色.

我发现的更多项目.颜色没有变化.可见性似乎是.然而,读取颜色和条形的alpha将返回1.0.

所以颜色是正确的.

半透明是肯定的.

Alpha是1.0.

然而,酒吧是完全清晰,没有颜色,没有色调.

我想我会将此正式归档为错误.我做了一个只有MKMapview的测试viewController.没有代码,没有代表,没有注释.提出代替我的适当控制器.同样的事情发生了.

我现在需要的是一种解决方法.我只是不知道有什么变化.当我检查导航栏的属性时,一切都是正确的.色调,半透明,条纹色调,alpha值.据我所知,事情应该按照预期显示.

谁能告诉我其他属性或方法可以使导航栏的背景完全透明?

iphone mkmapview ios uiappearance

7
推荐指数
1
解决办法
1996
查看次数

MFMailComposeViewController忽略了iOS 7中的一些UIAppearance协议

我有一个仅限iOS 7的应用程序,它使用UIAppearance来为整个应用程序中的UINavigationBar设置样式.

我的AppDelegate中有以下代码:

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

但是,MFMailComposeViewController会出现redImage背景!

文档说明如下:

要点:此类的视图层次结构是私有的,您不能修改它.但是,您可以使用UIAppearance协议自定义实例的外观.

所以没有理由说上面的内容不起作用,我100%肯定redImage并且blueImage是不同颜色的图像.

还有其他人遇到过这个问题吗?我猜它是iOS 7中的一个错误但我没有时间检查iOS 6(我通过使用iPad 4得到这些结果).

objective-c messageui ios uiappearance ios7

7
推荐指数
1
解决办法
1133
查看次数

在iOS7中,使用UIAppearance代理时,UIBarButtonItems不尊重粗体"完成"样式

在iOS7中,默认情况下,UIBarButtonItem对样式UIBarButtonItemStylePlain使用Helvetica常规权重字体,对UIBarButtonItemStyleDone使用粗体.

我的应用程序使用自定义字体,我使用UIAppearance代理来实现此目的:

appearance = @{NSFontAttributeName: [UIFont fontWithName:@"ProximaNova-Regular" size:18.0]};
[[UIBarButtonItem appearance] setTitleTextAttributes:appearance
                                            forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

麻烦的是,外观代理使Plain和Done样式按钮成为我上面指定的常规重量字体.

任何想法如何让UIBarButtonItem根据样式使用不同的自定义字体权重?

uikit uibarbuttonitem ios uiappearance ios7

7
推荐指数
1
解决办法
2057
查看次数

如何更改MFMailComposeViewController文本和按钮图像的颜色?

iOS在MFMailComposeViewController中为所有彩色文本使用标准(蓝色)色调颜色.这对我来说并不好,因为客户希望他的公司颜色在应用程序中.如何将颜色改为橙色?

我特别询问按钮图标(添加图像和铃声图像)的颜色和包含邮件地址的文本.我已经改变了导航栏的颜色.在文档中,有写:

此类的视图层次结构是私有的,您不能修改它.但是,您可以使用UIAppearance协议自定义实例的外观.

我试图使用它,但它不起作用(我可能做错了,因为我不知道UIAppearance).这是我尝试过的:

        [[UIButton appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

        [[UILabel appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTextColor:[UIColor orangeColor]];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

objective-c uiappearance mfmailcomposeviewcontroller

7
推荐指数
1
解决办法
1023
查看次数