我的应用在右侧栏按钮项custom badge上有徽章,当方向更改徽章转到导航栏的中间时
肖像
景观:
-(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];
}
如何稳定此徽章始终保持在同一位置(右侧栏按钮右上方)?
谢谢,
答案 0 :(得分:1)
尝试
_customBadge1.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleTopMargin);