0

我的应用程序在右栏按钮项目上有一个徽章,自定义徽章,当方向更改时,徽章转到导航栏的中间

肖像

在此处输入图像描述

景观:

在此处输入图像描述

-(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];

}

我怎样才能稳定这个始终保持在同一位置的徽章(在右栏按钮的右上方。)?

谢谢,

4

1 回答 1

1

尝试

_customBadge1.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
               UIViewAutoresizingFlexibleTopMargin);
于 2013-03-11T16:43:13.507 回答