IOS Unread Message Corner label imitation QQ drag and drop simple and flexible support Xib (source code)

Source: Internet
Author: User

First, the effect

Second, simple usage

Super simple, 2 lines of code integration, Xib 0 code integration, just drag a view associated Lfbadge class to

Pod import pod ' Lfkit/lfbadge ' supported

// general view _badge1 = [[Lfbadge alloc] init];[ _badge1 Addtotabbaritem:_view1]; // barbuttonitem superscript _badge2 = [[Lfbadge alloc] init];[ _badge2 AddToBarButtonItem:self.navigationItem.rightBarButtonItem]; // tabbaritem superscript _badge3 = [[Lfbadge alloc] init];[ _badge3 AddToTabBarItem:self.tabBarItem];

Assign value
@ "0" or nil hidden, @ "" shows red dots, numeric strings greater than Maxcount display maxcount++, other strings are displayed as they are (you can also display new)
_badge1.count = @ "1"
Iii. more Usage 1. Drag-and-drop removal

Add a clear callback has a drag function, no drag-and-drop function

_badge1.clearblock = ^{        NSLog (@ " clear Unread message corner Mark ");    };
2. Other functions that can be defined

See. h file for detailed comments

typedef ns_enum (Nsinteger, Lfbadgetype) {lfbadgetype_center,//Badge Center at the top right corner of the parent viewLfbadgetype_righttop,//badge the upper right corner to the upper right corner of the parent viewLfbadgetype_leftbottom//badge The lower left corner to the upper right corner of the parent view};/** Unread Message Corner Label control, support Xib and code 2 ways to use, support drag and drop erase*/@interfaceLfbadge:uiview@property (nonatomic, strong) Uicolor*badgecorlor;//Corner label color, default red@property (nonatomic, strong) UILabel *lbtext;//default white text, font 14, corner size automatically adapts to font size@property (nonatomic) BOOL needdisappeareffects;//need to disappear effects, explosion effects//maximum number, not set by default 99, to be set before count@property (nonatomic, assign) Nsinteger MaxCount;//@ "0" or nil hidden, @ "" shows red dots, numeric strings greater than Maxcount display maxcount++, other strings are displayed as they are (you can also display new)@property (nonatomic, copy) NSString *count; @property (nonatomic, assign) cgfloat reddotsize;//red dot size, not set by default 8@property (nonatomic, assign) CGFloat maxdistance;//the maximum distance of a large circle from a small circle/** The following 2 properties are invalid when you set another constraint or frame yourself * * **/@property (nonatomic) uiedgeinsets edgeinsets;//offset to the upper-right corner of the parent view, default Uiedgeinsetszero@property (nonatomic) lfbadgetype type;/** Drag to clear the callback (set this to have a drag effect)*/@property (nonatomic, copy)void(^clearblock) (void);/** Add to Parent view upper right corner (auto-constrain)*/- (void) Addtoview: (uiview*) Superview;/** Add the corner label to the upper-right corner of the Tabbaritem (automatic constraint)*/- (void) Addtotabbaritem: (Uitabbaritem *) Tabbaritem;/** Add the corner label to the upper-right corner of the Barbuttonitem (automatic constraint)*/- (void) Addtobarbuttonitem: (Uibarbuttonitem *) Barbuttonitem;/** Clear the corner label constraint (if you do not want to add to the upper-right corner of the parent view to adjust the method, and then set other constraints or frame)*/- (void) Clearbadgeconstraint;

Lfbadge is just a sub-library of Lfkit, source address Https://github.com/zhanglinfeng/LFKit

IOS Unread Message Corner label imitation QQ drag and drop simple and flexible support Xib (source code)

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.