1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > IOS 自定义导航栏标题和返回按钮标题

IOS 自定义导航栏标题和返回按钮标题

时间:2021-11-01 16:30:19

相关推荐

IOS 自定义导航栏标题和返回按钮标题

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=titleText;

[titleText release];

IOS中自定义导航栏返回按钮:(放在pushViewController之前)

UIBarButtonItem *backItem=[[UIBarButtonItemalloc]init];

backItem.title=@"后退";

backItem.tintColor=[UIColor colorWithRed:129/255.0 green:129/255.0 blue:129/255.0 alpha:1.0];

self.navigationItem.backBarButtonItem = backItem;

[backItem release];

IOS中自定义导航栏右边按钮

UIBarButtonItem *rightButton= [[UIBarButtonItemalloc]

initWithTitle:@"回到首页"

style:UIBarButtonItemStyleBordered

target:self

action:@selector(callModalList)];

rightButton.image=[UIImageimageNamed:@"right_button.png"];

rightButton.tintColor=[UIColor colorWithRed:74/255.0 green:74/255.0 blue:74/255.0 alpha:1.0];

self.navigationItem.rightBarButtonItem = rightButton;

[rightButton release];

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。