0

これはちょっとしたハックですが、toolbaritemでバッジを取得しようとしています。ほぼそこにありますが、後ろに表示されますが、運が悪かったので通常の方法で前に出てみました。

ツールバーの後ろ

deletedCountBadge = [CustomBadge customBadgeWithString:@"0"];
deletedCountBadge.frame = CGRectMake(100,10,25,25);

UIView *view = (UIView *)[bottomToolBar.subviews objectAtIndex:0];
[view addSubview:deletedCountBadge];
4

1 に答える 1

0

ネット上のいくつかの異なるポインタで動作するようになりました。

1)ツールバーを移動する場合(.frame =)は、レイアウト後に必ず項目を設定してください。

2)ネガティブスペーシングアイテムを使用して、必要な場所に表示させることができます。

ここに画像の説明を入力してください

UIBarButtonItem *deleteBadge = [BarButtonItemBadge barButtonItemBadge:@"1" insideColor:[UIColor blueColor]];

UIBarButtonItem *negativeSeperator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
negativeSeperator.width = -30;

[bottomToolBarDictionaryButtonItems addObject:deleteBadge];
[bottomToolBarDictionaryButtonItems addObject:negativeSeperator];

// after any layout, of tool bar

[bottomToolBar setItems:bottomToolBarDictionaryButtonItems];
于 2013-03-26T14:14:13.207 に答える