//添加消息通知 小红点iOS自带
NSArray *tabBarItems = self.navigationController.tabBarController.tabBar.items;
UITabBarItem *personCenterTabBarItem = [tabBarItems objectAtIndex:2];
personCenterTabBarItem.badgeValue = @"1";
//自定义方法(还需完善)
UIImageView *dotImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_speed_check"]];
dotImage.backgroundColor = [UIColor clearColor];
CGRect tabFrame =self.navigationController.tabBarController.tabBar.frame;
CGFloat x =ceilf(0.9 * tabFrame.size.width);
CGFloat y =ceilf(0.1 * tabFrame.size.height);
dotImage.frame =CGRectMake(x, y, 8,8);
[self.navigationController.tabBarController.tabBar addSubview:dotImage];
//应用图标添加提示
UIUserNotificationSettings *settings = [UIUserNotificationSettings
settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[UIApplication sharedApplication].applicationIconBadgeNumber = 2;
SVSettingsViewCtrl类中:
1.在- (UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath方法中添加
//第一次出现时添加
SVProbeInfo *probeInfo = [SVProbeInfo sharedInstance];
if (![probeInfo isFirstStart])
{
if (indexPath.row == 0)
{
// 显示新功能指引
[self showNewView:cell];
//设置首次启动标志位
[probeInfo setFirstStart:YES];
}
}
2.添加方法:
//添加新功能提示
-(void)showNewView :(UITableViewCell *)cell{
btn = [[UIButton alloc]init];
// 按钮类型
btn = [UIButton buttonWithType:UIButtonTypeCustom];
// 按钮尺寸
btn.frame = CGRectMake(FITWIDTH(200), cell.height *0.25, cell.height,cell.height*0.5);
// 按钮背景颜色
btn.backgroundColor = [UIColor redColor];
//设置文字
[btn setTitle:@"new" forState:UIControlStateNormal];
// 按钮圆角
btn.layer.cornerRadius = svCornerRadius (30
);
// 设置居中
btn.titleLabel.textAlignment = NSTextAlignmentCenter;
// 按钮文字颜色和类型
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// 设置字体大小
[btn.titleLabel setFont:[UIFont systemFontOfSize:pixelToFontsize (40)]];
// 设置按钮默认情况下不可交互
btn.enabled = NO;
[cell addSubview:btn];
}
//隐藏新功能提示
-(void)hideNewView{
[btn removeFromSuperview];
}
3.在- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath中添加
//第一次出现时添加
SVProbeInfo *probeInfo = [SVProbeInfo sharedInstance];
if (![probeInfo isFirstStart])
{
if (indexPath.row == 0)
{
[self hideNewView];
}
}