gpt4 book ai didi

iphone - 更改 rightBarButtonItem 的起始 y 轴

转载 作者:行者123 更新时间:2023-12-03 20:30:53 25 4
gpt4 key购买 nike

我在 rightBarButtonItem 上有以下自定义按钮

UIButton *button1 = [[UIButton alloc] init];
button1.frame=CGRectMake(0,0,105,30);
[button1 setBackgroundImage:[UIImage imageNamed: @"image1.png"] forState:UIControlStateNormal];
[button1 addTarget:appDelegate action:@selector(Open_Link1) forControlEvents:UIControlEventTouchUpInside];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button1];
[button1 release];

我需要将 rightBarButtonItem 向上移动 2 px ...

我尝试过设置但不起作用!

最佳答案

button1.imageEdgeInsets = UIEdgeInsetsMake(-4, 0, 0, 0);

答案在这里:Can I change the position of navigationbar item?

请注意,您更改的是分配给 rightBarButtonItem 的按钮的插图,而不是 rightBarButtonItem 本身。

关于iphone - 更改 rightBarButtonItem 的起始 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11245296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com