IOS message notification Little red dot & custom Little red dot & app icon add hint

Source: Internet
Author: User

Add message notifications Little Red dot iOS comes with

Nsarray *tabbaritems = Self.navigationController.tabBarController.tabBar.items;

Uitabbaritem *personcentertabbaritem = [Tabbaritems objectatindex:2];

Personcentertabbaritem.badgevalue = @ "1";

Custom method (also perfect)

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

Add a hint to an app icon

Uiusernotificationsettings *settings = [uiusernotificationsettings

Settingsfortypes:uiusernotificationtypebadge Categories:nil];

[[UIApplication sharedapplication] registerusernotificationsettings:settings];

[UIApplication sharedapplication].applicationiconbadgenumber = 2;

In the Svsettingsviewctrl class:

1. In-(UITableViewCell *) TableView: (UITableView *) Tableviewcellforrowatindexpath: (Nsindexpath *) Indexpath method add

Add when first appears

Svprobeinfo *probeinfo = [Svprobeinfo sharedinstance];

if (![ Probeinfo Isfirststart])

{

if (Indexpath.row = = 0)

{

Show new feature guidelines

[Self Shownewview:cell];

Set the first boot flag bit

[Probeinfo Setfirststart:yes];

}

}

2. Add a method:

Add new Feature Tips

-(void) Shownewview:(UITableViewCell *) cell{

BTN = [[UIButton alloc]init];

Button type

BTN = [UIButton buttonwithtype:uibuttontypecustom];

Button size

Btn.frame = CGRectMake (fitwidth), Cell.height *0.25, cell.height,cell.height*0.5);

Button background color

Btn.backgroundcolor = [Uicolor Redcolor];

Set text

[Btn settitle:@ "new" forstate:uicontrolstatenormal];

Button rounded Corners

Btn.layer.cornerRadius = Svcornerradius (30

);

Set Center

Btn.titleLabel.textAlignment = Nstextalignmentcenter;

button text color and type

[btn Settitlecolor:[uicolor Whitecolor] forstate:uicontrolstatenormal];

Set Font size

[Btn.titlelabel Setfont:[uifont Systemfontofsize:pixeltofontsize (40)];

The Settings button is not interactive by default

btn.enabled = NO;

[Cell ADDSUBVIEW:BTN];

}

Hide new Feature Tips

-(void) hidenewview{

[Btn Removefromsuperview];

}

3. In-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath add

Add when first appears

Svprobeinfo *probeinfo = [Svprobeinfo sharedinstance];

if (![ Probeinfo Isfirststart])

{

if (Indexpath.row = = 0)

{

[Self hidenewview];

}

}

IOS message notification Little red dot & custom Little red dot & app icon add hint

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.