您的位置:首页 > 其它

navigationBar中左右Item

2016-03-22 00:00 330 查看
摘要: 自定义navigationBar左右Item的字体(大小)

/*
// 系统箭头样式
UIBarButtonSystemItemPlay

*/

UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(rightButton)];

self.navigationItem.rightBarButtonItem = rightBtn;

// right itme (变相让按钮靠右)
UIButton * rightItemButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 40)];

// 设置 宽高 (需倒入工具类)
//rightItemButton = CGSizeMake(100, 40);

/*

// 加上边框
[rightItemButton.layer setBorderWidth:1.0f];

// 圆角
[rightItemButton.layer setCornerRadius:4.0f];

// 边框颜色
[rightItemButton.layer setBorderColor:[UIColor blackColor].CGColor];

*/

[rightItemButton setTitle:@"下一步" forState:UIControlStateNormal];

// 字体大小
rightItemButton.titleLabel.font = [UIFont systemFontOfSize:20];

// 颜色
[rightItemButton setTitleColor:[UIColor colorWithRed:0.000 green:0.431 blue:0.427 alpha:1.000] forState:UIControlStateNormal];

// 居中
[rightItemButton.titleLabel setTextAlignment:NSTextAlignmentCenter];

// 添加点击事件
[rightItemButton addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];

// 第一次见
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightItemButton];

// 状态 作用不明
//[rightButton setStyle:UIBarButtonItemStyleDone];

// 设置 右边time 为
[self.navigationItem setRightBarButtonItem:rightButton];

学自:http://www.cocoachina.com/bbs/read.php?tid-298084.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: