如何在UIBar按钮上添加徽章,如UITabBarController?

时间:2012-03-12 21:11:11

标签: iphone cocoa-touch ipad uibutton badge

我想知道如何为UIButton设置徽章,如UITabBarController Badge?

2 个答案:

答案 0 :(得分:0)

您只想将背景图像添加到按钮

    UIImage *image = [UIImage imageNamed:@"YourBadge.png"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(200.0, 10.0, 20.0, 20.0); // or whatever dimensions you want
    [button setBackgroundImage:image forState:UIControlStateNormal];

答案 1 :(得分:0)

您可以使用MKNumberBadgeView