Displaying notification badge like counter in UINavigationbar

后端 未结 3 1395
慢半拍i
慢半拍i 2021-01-25 07:09

I have a requirement to display number of pending notifications in iPhone navigation bar. The appearance should be like that of notification badge - but these are not APNS notif

3条回答
  •  灰色年华
    2021-01-25 07:43

    UIButton * buttton = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttton setFrame:CGRectMake(285, 20, 20, 20)];
    [buttton.layer setCornerRadius:10];
    [buttton setTitle:@"23" forState:UIControlStateNormal];
    [buttton.titleLabel setFont:[UIFont systemFontOfSize:12]];
    [buttton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [buttton setBackgroundColor:[UIColor whiteColor]];
    [self.navigationController.view addSubview:buttton];
    

提交回复
热议问题