文章来源:淘论文网   发布者: 毕业设计   浏览量: 25



还可以点击去查询以下关键词:
[任意]    [视图]    [添加]    [圆点]    [角标]    [文字]    [为任意视图添加圆点和角标文字]   

项目介绍:

关键代码-(void)yee_MakeBadgeText:(NSString *)text textColor:(UIColor *)tColor backColor:(UIColor *)backColor Font:(UIFont*)tfont{ if ([self yee_BadgeLable]==nil) {//如果没有绑定就重新创建,然后绑定 YeeBadgeLable *badgeLable =[[YeeBadgeLable alloc] init]; objc_setAssociatedObject(self, YeeBadgeLableString, badgeLable, OBJC_ASSOCIATION_RETAIN_NONATOMIC); [self addSubview:badgeLable]; } CGSize textSize=[self sizeWithString:text font:tfont constrainedToWidth:self.frame.size.width]; if ([self isKindOfClass:[UIButton class]]) { UIButton *weakButton=(UIButton*)self; [[self yee_BadgeLable] makeBrdgeViewWithText:text textColor:tColor backColor:backColor textFont:tfont tframe:CGRectMake(weakButton.imageView.frame.size.width*0.5+weakButton.imageView.frame.origin.x,weakButton.imageView.frame.origin.y, textSize.width+8.0, textSize.height)]; }else if ([self isKindOfClass:[UITabBarItem class]]){ }else{ [[self yee_BadgeLable] makeBrdgeViewWithText:text textColor:tColor backColor:backColor textFont:tfont tframe:CGRectMake(self.frame.size.width-(textSize.width+8.0)*0.5, -textSize.height*0.5, textSize.width+8.0, textSize.height)]; } } 用法 UIView *blueView=[[UIView alloc] init]; [blueView setFrame:CGRectMake(40, 70, 200, 20)]; [blueView yee_MakeBadgeText:@'' textColor:[UIColor whiteColor] backColor:[UIColor redColor] Font:[UIFont systemFontOfSize:10]]; [blueView setBackgroundColor:[UIColor blueColor]]; [self.view addSubview:blueView]; UIView *grayView=[[UIView alloc] init]; [grayView setFrame:CGRectMake(40, 120, 200, 20)]; [grayView yee_MakeBadgeText:@'100' textColor:[UIColor whiteColor] backColor:[UIColor redColor] Font:[UIFont systemFontOfSize:10]]; [grayView setBackgroundColor:[UIColor grayColor]]; [self.view addSubview:grayView]; UIButton *buttonView=[UIButton buttonWithType:UIButtonTypeCustom]; [buttonView setFrame:CGRectMake(40, 180, 50, 40)]; [buttonView setImage:[UIImage imageNamed:@'artical_detail_icon_comment_disabled'] forState:UIControlStateNormal]; [buttonView yee_MakeBadgeText:@'2345' textColor:[UIColor whiteColor] backColor:[UIColor redColor] Font:[UIFont systemFontOfSize:9]]; [self.view addSubview:buttonView];

demo请戳这里,demo会一直更新,论文,如有问题可以pull,开题报告,希望能帮助到你。


这里还有:


还可以点击去查询:
[任意]    [视图]    [添加]    [圆点]    [角标]    [文字]    [为任意视图添加圆点和角标文字]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/6239.docx
  • 上一篇:自定义弹出定制框和toast
  • 下一篇:真实逻辑滚动数定制字DPScrollNumberLabel