gpt4 book ai didi

ios - 角标(Badge)在右栏按钮项目上的稳定位置

转载 作者:行者123 更新时间:2023-11-29 04:05:26 27 4
gpt4 key购买 nike

我的应用程序的右栏按钮项上有一个角标(Badge),custom badge ,当方向改变时,角标(Badge)会转到导航栏的中间

肖像

enter image description here

风景:

enter image description here

-(void)viewDidAppear:(BOOL)animated
{
_customBadge1 = [CustomBadge customBadgeWithString:@"2"
withStringColor:[UIColor whiteColor]
withInsetColor:[UIColor redColor]
withBadgeFrame:YES
withBadgeFrameColor:[UIColor whiteColor]
withScale:1.0
withShining:YES];

// Set Position of Badge
CGRect frameimgback2 = CGRectMake(742, 0, 20, 20);
_customBadge1.frame=frameimgback2;
[self.navigationController.navigationBar addSubview:_customBadge1];

}

我怎样才能稳定这个角标(Badge),使其始终保持在同一位置(在右栏按钮的右上角)?

谢谢

最佳答案

尝试

_customBadge1.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleTopMargin);

关于ios - 角标(Badge)在右栏按钮项目上的稳定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15343835/

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