新的ios5api:自定义UINavigationBar背景属性与简单的功能!!!
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新的ios5api:自定义UINavigationBar背景属性与简单的功能!!!相关的知识,希望对你有一定的参考价值。
Here is a nice function you can use to implement a custom background for your UINavigation BarsSimply make two images in photoshop:
32 x 32
44 x 44
and name them whatever you want.
put them in your iPhone project by dragging and dropping them from the desktop or another directory.
If need be check the Copy Group Destination files in folder line to add the two image files to your project.
Make sure you replace the two lines that create the UIImages with your image names
Copy And paste the function into your app delegate right above applicationDidFinishLaunchingWithOptions:
then simply call
[self customizeAppearance]; inside your app delegate and...
voila, enjoy :)
- (void)customizeAppearance { // Create resizable images UIImage *gradientImage44 = [[UIImage imageNamed:@"gradient_textured_44"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; UIImage *gradientImage32 = [[UIImage imageNamed:@"gradient_textured_32"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; // Set the background image for *all* UINavigationBars [[UINavigationBar appearance] setBackgroundImage:gradientImage44 forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundImage:gradientImage32 forBarMetrics:UIBarMetricsLandscapePhone]; // Customize the title text for *all* UINavigationBars [[UINavigationBar appearance] setTitleTextAttributes: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], UITextAttributeTextShadowColor, UITextAttributeTextShadowOffset, [UIFont fontWithName:@"Arial-Bold" size:0.0], UITextAttributeFont, nil]]; }
以上是关于新的ios5api:自定义UINavigationBar背景属性与简单的功能!!!的主要内容,如果未能解决你的问题,请参考以下文章
在 UINavigationbar 的标题视图中添加自定义 UIView
关闭 UIAlertController 时调用 UINavigation 的 dismissViewControllerAnimated 方法
当 UINavigation 的 Translucent 设置为 false 时,视图约束发生变化
uinavigationcontroller返回按钮文字设定
UINavigationController interactivePopGestureRecognizer在iOS7中工作异常