独角兽企业重金招聘Python工程师标准>>>
-(CATextLayer*)creatBadgeLayer{CATextLayer*badgeLayer=[[CATextLayeralloc]init];badgeLayer.backgroundColor=[UIColorredColor].CGColor;badgeLayer.foregroundColor=[UIColorwhiteColor].CGColor;badgeLayer.alignmentMode=kCAAlignmentCenter;[badgeLayersetFrame:CGRectMake(0,0,18,18)];badgeLayer.position=CGPointMake(20,3);badgeLayer.wrapped=YES;badgeLayer.cornerRadius=9.0f;[badgeLayersetFontSize:13];[badgeLayersetString:@"1"];badgeLayer.anchorPoint=CGPointZero;badgeLayer.contentsScale=[[UIScreenmainScreen]scale];returnbadgeLayer;}//给控件添加badge[btn.layeraddSublayer:[selfcreatBadgeLayer]];
如果觉得《Ios上任意控件上添加自定义Badge》对你有帮助,请点赞、收藏,并留下你的观点哦!