怎么把dnf每日签到2017设置到导航栏上

&//修改导航栏颜色字体大小
& & self.navigationController.navigationBar.titleTextAttributes
= @{NSForegroundColorAttributeName: [UIColor
whiteColor],NSFontAttributeName : [UIFont
boldSystemFontOfSize:18]};
本文是使用纯代码实现一个导航栏的效果。单击按钮并且产生事件。基本思路是:
1.创建一个导航栏(UINavigationBar对象)
2.创建一个导航栏集合(UINavigationItem对象)
3.创建一个左边按钮、一个右边按钮(UIBarButtonItem对象),并实现对应的事件方法
4.将导航栏集合添加到导航栏中,设置动画关闭
5.把左右两个按钮添加到导航栏集合中去
6.在视图中显示当前创建的导航栏
具体的实现代码如下:
ViewController.h文件中的代码不用改变,如下所示:
[cpp] view plaincopy
#import &UIKit/UIKit.h& &
@interface ViewController : UIViewController &
ViewController.m文件中的代码:
[cpp] view plaincopy
#import &ViewController.h& &
@interface ViewController () &
@implementation ViewController &
- (void)viewDidLoad &
& & [super viewDidLoad]; &
& & // Do any additional setup after loading the view, typically from a nib. &
& & //创建一个导航栏 &
& & UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; &
& & //创建一个导航栏集合 &
& & UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:nil]; &
& & //在这个集合Item中添加标题,按钮 &
& & //style:设置按钮的风格,一共有三种选择 &
& & //action:@selector:设置按钮的点击事件 &
& & //创建一个左边按钮 &
& & UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@&左边& style:UIBarButtonItemStyleBordered target:self action:@selector(clickLeftButton)]; &
& & //创建一个右边按钮 &
& & UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@&右边& style:UIBarButtonItemStyleDone target:self action:@selector(clickRightButton)]; &
& & //设置导航栏的内容 &
& & [navItem setTitle:@&凌凌漆&]; &
& & //把导航栏集合添加到导航栏中,设置动画关闭 &
& & [navBar pushNavigationItem:navItem animated:NO]; &
& & //把左右两个按钮添加到导航栏集合中去 &
& & [navItem setLeftBarButtonItem:leftButton]; &
& & [navItem setRightBarButtonItem:rightButton]; &
& & //将标题栏中的内容全部添加到主视图当中 &
& & [self.view addSubview:navBar]; &
& & //最后将控件在内存中释放掉,以避免内存泄露 &
& & [navItem release]; &
& & [leftButton release]; &
& & [rightButton release]; &
-(void)showDialog:(NSString *)str &
& & UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&这是一个对话框& message:str delegate:self cancelButtonTitle:@&确定& otherButtonTitles: nil]; &
& & [alert show]; &
& & [alert release]; &
-(void) clickLeftButton &
& & [self showDialog:@&点击了导航栏左边按钮&]; &
-(void) clickRightButton &
& & [self showDialog:@&点击了导航栏右边按钮&]; &
- (void)viewDidUnload &
& & [super viewDidUnload]; &
& & // Release any retained subviews of the main view. &
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation &
& & return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); &
1: & 有时候我不想用系统的导航栏,但是要用到push界面。
& &DimmingViewController *dimmingViewController = [[DimmingViewControlleralloc]init];
& & & & & &UINavigationController *nav = [[UINavigationControlleralloc]initWithRootViewController:dimmingViewController];
& & & & & & [nav.navigationControllersetNavigationBarHidden:YES];
& & & & & &self.window.rootViewController =
b.在DimmingViewController中设置
- (void)viewDidLoad
& & &&if&([self&respondsToSelector:@selector(setEdgesForExtendedLayout:)])&
& & & & & &&self.edgesForExtendedLayout&=&UIRectEdgeNone;
- (void) viewDidAppear:(BOOL)animated
& & [superviewDidAppear:animated];
& & [self.navigationControllersetNavigationBarHidden:YESanimated:NO];
- (void) viewDidDisappear:(BOOL)animated
& & [superviewDidDisappear:animated];
& & [self.navigationControllersetNavigationBarHidden:YESanimated:NO];
2:自定义导航栏上的一些元素
IOS中自定义导航栏标题:
&UILabel&*titleText = [[UILabel&alloc]&initWithFrame:&CGRectMake(160,&0,&120,&50)];
&titleText.backgroundColor&= [UIColor&clearColor];
&titleText.textColor=[UIColor&whiteColor];
&[titleText&setFont:[UIFont&systemFontOfSize:17.0]];
&[titleText&setText:@&XXX&];
&self.navigationItem.titleView=titleT
&[titleText&release];
IOS中自定义导航栏返回按钮:(放在pushViewController之前)
&&UIBarButtonItem&*backItem=[[UIBarButtonItem&alloc]init];
&&backItem.title=@&后退&;
& backItem.tintColor=[UIColor&colorWithRed:129/255.0&green:129/255.0
&blue:129/255.0&alpha:1.0];
&&self.navigationItem.backBarButtonItem&= backI
&&[backItem&release];
IOS中自定义导航栏右边按钮
UIBarButtonItem&*&rightButton&= [[UIBarButtonItem&alloc]
& & & & & & & & & & & & & & & & & & & & & & & &&initWithTitle:@&回到首页&
& & & & & & & & & & & & & & & & & & & & & & & &&style:UIBarButtonItemStyleBordered
& & & & & & & & & & & & & & & & & & & & & & & &&target:self
& & & & & & & & & & & & & & & & & & & & & & & &&action:@selector(callModalList)];
rightButton.image=[UIImage&imageNamed:@&right_button.png&];
rightButton.tintColor=[UIColor&colorWithRed:74/255.0&green:74/255.0&blue:74/255.0&alpha:1.0];
self.navigationItem.rightBarButtonItem&= rightB
[rightButton&release];
导航控制器可以用几种不同的风格来显示自身。默认风格就是标准的灰色外观。目前支持三种不同的风格。
风&&& 格
UIBarStyleDefault
默认风格;灰色背景,白色文字
UIBarStyleBlack
纯黑色背景,白色文字
UIBarStyleBlackOpaque
纯黑色背景,白色文字&&&&&&&&
UIBarStyleBlackTranslucent
透明黑色背景,白色文字
风格是通过barStyle属性来设置的。这个属性属于导航控制器,而不是视图控制器,因此在各个视图之间来回切换时,此属性可以保持一致:
self.navigationController.navigationBar.barStyle&=&UIBarStyleBlackT&
<span style="font-size:24 color:#:
在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更改一下背景和颜色,
代码会很简单,不需要很复杂的自定义View来替代leftBarItem
更改导航栏的背景和文字Color
//set NavigationBar 背景颜色&title 颜色 &
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]]; &
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]]; &
效果如下:
我们把背景改成了蓝色,title文字改成了白色,是不是很简单呢?NavigationBar极其push过去的子页面也会是你修改后的背景颜色
//设置NavigationBar背景颜色 &
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]]; &
//@{}代表Dictionary &
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];&
效果如下:
在导航栏使用背景图片:
如果您的应用程序使用了自定义图像作为栏的背景,你需要提供一个“更大”的图片,使其延伸了状态栏的后面。
导航栏的高度现在是从44点(88像素)更改为64点(128像素)。
仍然可以使用了setBackgroundImage:方法来指定自定义图像的导航栏。下面是代码行设置背景图片:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@&nav_bg.png&] forBarMetrics:UIBarMetricsDefault]; &
效果图和上面的一样,我就不贴出来了。
改变导航栏标题的字体
就像iOS 6,我们可以通过使用导航栏的“titleTextAttributes”属性来自定义的文本样式。可以指定字体,文字颜色
,文字阴影颜色,文字阴影在文本标题偏移属性字典,使用下面的文本属性键:
UITextAttributeFont - 字体
UITextAttributeTextColor - 文字颜色
UITextAttributeTextShadowColor - 文字阴影颜色
UITextAttributeTextShadowOffset - 偏移用于文本阴影
NSShadow *shadow = [[NSShadow alloc] init]; &
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]; &
shadow.shadowOffset = CGSizeMake(0, 1); &
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: &
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, &
shadow, NSShadowAttributeName, &
[UIFont fontWithName:@&HelveticaNeue-CondensedBlack& size:21.0], NSFontAttributeName, nil nil]]; &
使用图片作为导航栏标题
不想标题栏是光秃秃的文字?可以通过使用代码行中的图像或标志取代它:简单地改变titleview用来自定义,(适用于较低版本)
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@&appcoda-logo.png&]];&
效果如下,我随便用了个图片,别介意:
添加多个栏按钮项目
您希望添加导航栏的一侧不止一个栏按钮项目,无论是leftBarButtonItems和rightBarButtonItems
&您在导航栏左侧/右侧指定自定义栏按钮项目。比如你想添加一个摄像头和一个共享按钮右侧的吧。您可以使用下面的代码:
UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemAction target:self action: nil nil]; &
UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemCamera target:self action: nil nil]; &
NSArray *itemsArr = @[shareItem,cameraItem]; &
self.navigationItem.rightBarButtonItems = itemsA &
自定义后退按钮的文字和颜色
通常情况下,我们使用UINavigationController时,push到的子页面,左上角会是系统自动取&#20540;上一层父页面的title名称
,默认情况是这样,那么我们该如何修改它呢?
左侧显示了父页面的title:用户登录,可是我们想修改成返回,方式有很多,举些例子
通过设置navigationItem的backBarButtonItem可以直接更换文字,【注意,要在父视图的Controller中设置】如下:
UIBarButtonItem *item = [[UIBarButtonItem alloc]&
& & & & & & initWithTitle:@&返回&&
& & & & & & style:UIBarButtonItemStylePlain target:nil action:nil]; &
self.navigationItem.backBarButtonItem = &
效果如下:
所有的子界面返回时都变成了我们定义的文字,如果不想显示文字,直接&&,就会单独显示一个系统的返回箭头图标,
也是很清晰的感觉。
做到这里发现文字颜色和背景有重复,那么如何自定义其颜色呢?在iOS7,可以改变tintColor属性,
它提供了一个快速和简单的方式,下面是一个示例代码片段:
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; &
效果如下:
全是系统的图标和文字,这回看着舒服了,有木有?【除了后退按钮,请注意,tintColor属性影响所有按钮标题和按钮图像】
最后举个例子,另外一种实现自定义导航控制器返回按钮,代码如下:
&[self.navigationController.navigationBar&
& & & & & setTitleTextAttributes:@{NSForegroundColorAttributeName:
& & & & & [UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}]; &
self.title=[NSString stringWithFormat:@&第%lu页&,
& & & & & & & &(unsigned long)self.navigationController.viewControllers.count]; &
//自定义返回按钮 &
UIImage *backButtonImage = [[UIImage imageNamed:@&fanhui.png&]&
& & & & & & & resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:
& & & & & backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//将返回按钮的文字position设置不在屏幕上显示 &
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:
UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault]; &
效果如下:
最后说一下使用pushViewController切换到下一个视图时,navigation controller按照以下3条顺序更改导航栏的左侧按钮(本段摘自网络):
1、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;
2、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;
3、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:24995次
排名:千里之外
原创:37篇
转载:19篇
(1)(1)(2)(2)(3)(3)(3)(7)(28)(1)(6)转:ios导航栏设置 - 守望远方 - 博客园
随笔 - 210
原帖:/industry/7.html
本文提供的代码需要用Xcode 5来执行。如果你还在使用老版本的Xcode,那么在运行示例之前请将Xcode升级到Xcode 5。
iOS 7中默认的导航栏
在开始定制之前,我们先来看看iOS 7中默认导航栏的外观。通过Xcode用Single View Controller模板创建一个工程。然后将view controller嵌入到一个navigation controller中。如果你不想从头开始,那么也可以在这里下载到这个。Xcode 5包含有iOS 6和iOS 7模拟器,我们可以在这两个不同的模拟器版本中运行示例程序,进行对比,如下图所示:
如上图所示,在iOS 7中的导航栏默认情况下跟状态栏是交织在一起的,并且它的颜色也被修改为亮灰色。
设置导航栏的背景颜色
在iOS 7中,不再使用tintColor属性来设置导航栏的颜色,而是使用barTintColor属性来修改背景色。我们可以在AppDelegate.m文件中的方法didFinishLaunchingWithOptions:里面添加如下代码来修改颜色:
[[UINavigationBar&appearance]&setBarTintColor:[UIColor&yellowColor]];&
效果如下图所示:
一般情况,我们都会使用自己的颜色,下面这个宏用来设置RGB颜色非常方便:
#define&UIColorFromRGB(rgbValue)&[UIColor&colorWithRed:((float)((rgbValue&&&0xFF0000)&&&&16))/255.0&green:((float)((rgbValue&&&0xFF00)&&&&8))/255.0&blue:((float)(rgbValue&&&0xFF))/255.0&alpha:1.0]&
将上面这个宏放到AppDelegate.m文件中,然后通过这个宏来创建一个UIColor对象(根据指定的RGB)。如下示例:
[[UINavigationBar&appearance]&setBarTintColor:UIColorFromRGB(0x067AB5)];&
默认情况下,导航栏的translucent属性为YES。另外,系统还会对所有的导航栏做模糊处理,这样可以让iOS 7中导航栏的颜色更加饱和。如下图,是translucent值为NO和YES的对比效果:
要想禁用translucent属性,可以在Storyboard中选中导航栏,然后在Attribute Inspectors中,取消translucent的勾选。
在导航栏中使用背景图片
如果希望在导航栏中使用一个图片当做背景,那么你需要提供一个稍微高一点的图片(这样可以延伸到导航栏背后)。导航栏的高度从44 points(88 pixels)变为了64 points(128 pixels)。我们依然可以使用setBackgroundImage:方法为导航栏设置自定义图片。如下代码所示:
[[UINavigationBar&appearance]&setBackgroundImage:[UIImage&imageNamed:@"nav_bg.png"]&forBarMetrics:UIBarMetricsDefault];&
示例工程中提供了两个背景图片:nav_bg.png 和 nav_bg_ios7.png。运行一下试试看吧,如下效果:
定制返回按钮的颜
在iOS 7中,所有的按钮都是无边框的。其中返回按钮会有一个V型箭头,以及上一个屏幕中的标题(如果上一屏幕的标题是空,那么就显示&返回&)。要想给返回按钮着色,可以使用tintColor属性。如下代码所示:
[[UINavigationBar&appearance]&setTintColor:[UIColor&whiteColor]];&
除了返回按钮,tintColor属性会影响到所有按钮标题和图片。
如果想要用自己的图片替换V型,可以设置图片的backIndicatorImage和backIndicatorTransitionMaskImage。如下代码所示:
[[UINavigationBar&appearance]&setBackIndicatorImage:[UIImage&imageNamed:@"back_btn.png"]];&
[[UINavigationBar&appearance]&setBackIndicatorTransitionMaskImage:[UIImage&imageNamed:@"back_btn.png"]];&
图片的颜色是由tintColor属性控制的。
修改导航栏标题的字体
跟iOS 6一样,我们可以使用导航栏的titleTextAttributes属性来定制导航栏的文字风格。在text attributes字典中使用如下一些key,可以指定字体、文字颜色、文字阴影色以及文字阴影偏移量:
UITextAttributeFont & 字体key
UITextAttributeTextColor & 文字颜色key
UITextAttributeTextShadowColor & 文字阴影色key
UITextAttributeTextShadowOffset & 文字阴影偏移量key
如下代码所示,对导航栏的标题风格做了修改:
NSShadow&*shadow&=&[[NSShadow&alloc]&init];&
&&&&shadow.shadowColor&=&[UIColor&colorWithRed:0.0&green:0.0&blue:0.0&alpha:0.8];&
&&&&shadow.shadowOffset&=&CGSizeMake(0,&1);&
&&&&[[UINavigationBar&appearance]&setTitleTextAttributes:&[NSDictionary&dictionaryWithObjectsAndKeys:&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&[UIColor&colorWithRed:245.0/255.0&green:245.0/255.0&blue:245.0/255.0&alpha:1.0],&NSForegroundColorAttributeName,&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&shadow,&NSShadowAttributeName,&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&[UIFont&fontWithName:@"HelveticaNeue-CondensedBlack"&size:21.0],&NSFontAttributeName,&nil]];&
运行效果如下图所示:
修改导航栏标题为图片
如果要想将导航栏标题修改为一个图片或者logo,那么只需要使用下面这行代码即可:
self.navigationItem.titleView&=&[[UIImageView&alloc]&initWithImage:[UIImage&imageNamed:@"appcoda-logo.png"]];&
上面的代码简单的修改了titleView属性,将一个图片赋值给它。 注意:这不是iOS 7中的新功能,之前的iOS版本就可以已经有了。具体效果如下图所示:
添加多个按钮
同样,这个技巧也不是iOS 7的,开发者经常会在导航栏中添加多个按钮,所以我决定在这里进行介绍。我们可以在导航栏左边或者右边添加多个按钮。例如,我们希望在导航栏右边添加一个照相机和分享按钮,那只需要使用下面的代码即可:
UIBarButtonItem&*shareItem&=&[[UIBarButtonItem&alloc]&initWithBarButtonSystemItem:UIBarButtonSystemItemAction&target:self&action:nil];&
UIBarButtonItem&*cameraItem&=&[[UIBarButtonItem&alloc]&initWithBarButtonSystemItem:UIBarButtonSystemItemCamera&target:self&action:nil];&
NSArray&*actionButtonItems&=&@[shareItem,&cameraItem];&
self.navigationItem.rightBarButtonItems&=&actionButtonI&
如下效果:
修改状态栏的风格
在老版本的iOS中,状态栏永远都是白色风格。而在iOS 7中,我们可以修改每个view controller中状态栏的外观。通过UIStatusBarStyle常量可以指定状态栏的内容是暗色或亮色。默认情况下,状态栏的显示是暗色。也就是说,状态栏上的时间、电池指示器和Wi-Fi信号显示为暗色。如果导航栏中使用暗色为背景,那么看起来的效果如下图所示:
如上图这种情况下,我们可能希望将导航栏的风格修改为亮色。这里有两个方法可以实现。在iOS 7中,我们可以在每个view controller中overridingpreferredStatusBarStyle:方法,如下所示:
-(UIStatusBarStyle)preferredStatusBarStyle&
&&&&return&UIStatusBarStyleLightC&
上面代码的效果如下图所示:
在iOS 7中,通过上面的方法来修改状态栏风格非常的棒。另外,我们也可以使用UIApplication的statusBarStyle方法来设置状态栏,不过,首先需要停止使用View controller-based status bar appearance。在project target的Info tab中,插入一个新的key,名字为View controller-based status bar appearance,并将其值设置为NO。
然后就可以使用下面的代码来设置状态栏风格了:
[[UIApplication&sharedApplication]&setStatusBarStyle:UIStatusBarStyleLightContent];&
隐藏状态栏
有时候我们需要隐藏状态栏,那么此时我们在view controller中override方法prefersStatusBarHidden:即可,如下代码所示:
-&(BOOL)prefersStatusBarHidden&
&&&&return&YES;&
iOS 7给开发者提供了一些新的自由度来定制导航栏和状态栏的外观。希望上面的这些技巧能对你有用。这里可以下载到。只需要取消相关代码注释即可进行测试。查看: 2412|回复: 9
为什么我装了每日签到官方插件,导航栏上没有显示
为什么我装了每日签到官方插件,导航栏上没有显示,入口在哪里呢?家排网论坛请高手帮忙看下,谢谢了啊
【DSU】每日签到 4.7
dsu_paulsign& && && && && && && & 装的是这个
可啊 伦理电影
/plugin.php?id=dsu_paulsign:sign
您可以检查下导航栏设置或将此链接手动添加到合适位置
感谢您对DSU的支持
后台导航栏 添加 每日签到 即可
帮你顶一下,希望我的表现能为你争取多一点的展现时间,从而达到让dz牛人们看到你的问题,并回答你!
美国vps http://www.im288.net
yangtong 发表于
/plugin.php?id=dsu_paulsign:sign
您可以检查下导航栏设置或将此链接手动添加到 ...
搞定了,谢谢哈
我安装了好几个插件。。。都不 在导航栏显示。。。。&&都不知道安到哪里去了、、、、、郁闷,。。求解。。。。2.5&&.2012.7月更新的那个....
Powered by站长推荐 /2
凯立德V6.0主程序海涵地负专属算号器
万能版地图
Powered by

我要回帖

更多关于 dnf每日签到礼盒 的文章

 

随机推荐