Design idea: Add a category to the UIView all views can be displayed as needed for red dots
#import <UIKit/UIKit.h> @interface UIView (Chrreddot) @property (readonly, nonatomic) Calayer * chr_reddotlayer; /** the position of the center of the red Dot, and the distance from each edge.
If the distance is <=0, the distance/@property (nonatomic, assign) Uiedgeinsets chr_reddotedgeinsets is ignored;
/** Red dot radius, the default is 4 * * * * @property (nonatomic, assign) CGFloat Chr_reddotradius;
/** red dot color, default to 0XFF5A5A * * * * @property (nonatomic, Strong) Uicolor * CHR_REDDOTCOLOR;
/** red dot whether show * * * @property (nonatomic, assign) BOOL chr_reddotshow;
@end #pragma mark-method-(void) Chr_updatereddot {calayer *reddot = Self.chr_reddotlayer;
if (self.chr_reddotshow) {if (RedDot = = nil) {RedDot = [calayer layer];
Self.chr_reddotlayer = RedDot;
[Self.layer Addsublayer:reddot];
} Reddot.backgroundcolor = Self.chr_redDotColor.CGColor;
[Self Chr_layoutreddot];
else {[RedDot removefromsuperlayer];
Self.chr_reddotlayer = nil;
}-(void) Chr_layoutreddot {calayer *reddot = Self.chr_reddotlayer;
if (RedDot = = nil) return; CGFloatradius = Self.chr_reddotradius;
Reddot.cornerradius = radius;
Uiedgeinsets edgeinsets = self.chr_reddotedgeinsets; CGFloat Originx = edgeinsets.right <= 0?
Edgeinsets.left-radius:self.bounds.size.width-edgeinsets.right + radius; CGFloat originy = Edgeinsets.bottom <= 0?
Edgeinsets.top-radius:self.bounds.size.height-edgeinsets.bottom + radius;
CGFloat length = radius * 2;
Reddot.frame = CGRectMake (Originx, originy, length, length); }
The above is a small series of iOS to introduce similar micro-letter red dot display function, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!